[email protected] | c4ff495 | 2010-01-08 19:12:47 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
5 | // When each service is created, we set a flag indicating this. At this point, | ||||
6 | // the service initialization could fail or succeed. This allows us to remember | ||||
7 | // if we tried to create a service, and not try creating it over and over if | ||||
8 | // the creation failed. | ||||
9 | |||||
[email protected] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 10 | #ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ |
11 | #define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame^] | 12 | #pragma once |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
14 | #include <string> | ||||
15 | |||||
16 | #include "base/basictypes.h" | ||||
17 | #include "base/message_loop.h" | ||||
18 | #include "base/non_thread_safe.h" | ||||
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 19 | #include "base/timer.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 20 | #include "base/scoped_ptr.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 21 | #include "chrome/browser/browser_process.h" |
[email protected] | 67a46b7f | 2009-06-16 21:41:02 | [diff] [blame] | 22 | #include "chrome/browser/tab_contents/thumbnail_generator.h" |
[email protected] | d55aaa13 | 2009-09-28 21:08:04 | [diff] [blame] | 23 | #include "ipc/ipc_message.h" |
[email protected] | b112a4c | 2009-02-01 20:24:01 | [diff] [blame] | 24 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 25 | class CommandLine; |
[email protected] | a9bf6798 | 2010-07-06 10:13:00 | [diff] [blame] | 26 | class DebuggerWrapper; |
[email protected] | 4ef795df | 2010-02-03 02:35:08 | [diff] [blame] | 27 | class FilePath; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 28 | class NotificationService; |
[email protected] | 0b4d338 | 2010-07-14 16:13:04 | [diff] [blame] | 29 | class TabCloseableStateWatcher; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 30 | |
31 | // Real implementation of BrowserProcess that creates and returns the services. | ||||
32 | class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { | ||||
33 | public: | ||||
[email protected] | f3a4f30 | 2009-08-21 22:35:29 | [diff] [blame] | 34 | explicit BrowserProcessImpl(const CommandLine& command_line); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 35 | virtual ~BrowserProcessImpl(); |
36 | |||||
37 | virtual void EndSession(); | ||||
38 | |||||
[email protected] | e13ad79b | 2010-07-22 21:36:50 | [diff] [blame] | 39 | virtual ResourceDispatcherHost* resource_dispatcher_host(); |
40 | virtual MetricsService* metrics_service(); | ||||
41 | virtual IOThread* io_thread(); | ||||
42 | virtual base::Thread* file_thread(); | ||||
43 | virtual base::Thread* db_thread(); | ||||
44 | virtual base::Thread* process_launcher_thread(); | ||||
45 | virtual base::Thread* cache_thread(); | ||||
[email protected] | 25d47c7b | 2010-02-03 20:13:06 | [diff] [blame] | 46 | #if defined(USE_X11) |
[email protected] | e13ad79b | 2010-07-22 21:36:50 | [diff] [blame] | 47 | virtual base::Thread* background_x11_thread(); |
[email protected] | 4c3cd741 | 2009-04-22 17:56:06 | [diff] [blame] | 48 | #endif |
[email protected] | e13ad79b | 2010-07-22 21:36:50 | [diff] [blame] | 49 | virtual ProfileManager* profile_manager(); |
50 | virtual PrefService* local_state(); | ||||
51 | virtual DevToolsManager* devtools_manager(); | ||||
52 | virtual Clipboard* clipboard(); | ||||
53 | virtual NotificationUIManager* notification_ui_manager(); | ||||
54 | virtual StatusTrayManager* status_tray_manager(); | ||||
55 | virtual IconManager* icon_manager(); | ||||
56 | virtual ThumbnailGenerator* GetThumbnailGenerator(); | ||||
57 | virtual AutomationProviderList* InitAutomationProviderList(); | ||||
58 | virtual void InitDebuggerWrapper(int port, bool useHttp); | ||||
[email protected] | b443cb04 | 2009-12-15 22:05:09 | [diff] [blame] | 59 | virtual unsigned int AddRefModule(); |
[email protected] | b443cb04 | 2009-12-15 22:05:09 | [diff] [blame] | 60 | virtual unsigned int ReleaseModule(); |
[email protected] | e13ad79b | 2010-07-22 21:36:50 | [diff] [blame] | 61 | virtual bool IsShuttingDown(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 62 | virtual printing::PrintJobManager* print_job_manager(); |
[email protected] | e13ad79b | 2010-07-22 21:36:50 | [diff] [blame] | 63 | virtual GoogleURLTracker* google_url_tracker(); |
64 | virtual IntranetRedirectDetector* intranet_redirect_detector(); | ||||
65 | virtual const std::string& GetApplicationLocale(); | ||||
[email protected] | f1b6de2 | 2010-03-06 12:13:47 | [diff] [blame] | 66 | virtual void SetApplicationLocale(const std::string& locale); |
[email protected] | e13ad79b | 2010-07-22 21:36:50 | [diff] [blame] | 67 | virtual base::WaitableEvent* shutdown_event(); |
68 | virtual TabCloseableStateWatcher* tab_closeable_state_watcher(); | ||||
[email protected] | 6641bf66 | 2009-08-21 00:34:09 | [diff] [blame] | 69 | virtual void CheckForInspectorFiles(); |
70 | |||||
[email protected] | 3cdacd4 | 2010-04-30 18:55:53 | [diff] [blame] | 71 | #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 72 | void StartAutoupdateTimer(); |
[email protected] | 3cdacd4 | 2010-04-30 18:55:53 | [diff] [blame] | 73 | #endif |
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 74 | |
[email protected] | e13ad79b | 2010-07-22 21:36:50 | [diff] [blame] | 75 | virtual bool have_inspector_files() const; |
[email protected] | 6641bf66 | 2009-08-21 00:34:09 | [diff] [blame] | 76 | |
[email protected] | d55aaa13 | 2009-09-28 21:08:04 | [diff] [blame] | 77 | #if defined(IPC_MESSAGE_LOG_ENABLED) |
78 | virtual void SetIPCLoggingEnabled(bool enable); | ||||
79 | #endif | ||||
80 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 81 | private: |
[email protected] | 4ef795df | 2010-02-03 02:35:08 | [diff] [blame] | 82 | void ClearLocalState(const FilePath& profile_path); |
83 | bool ShouldClearLocalState(FilePath* profile_path); | ||||
84 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 85 | void CreateResourceDispatcherHost(); |
86 | void CreatePrefService(); | ||||
87 | void CreateMetricsService(); | ||||
[email protected] | 48ca901 | 2009-08-11 21:38:54 | [diff] [blame] | 88 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 89 | void CreateIOThread(); |
[email protected] | 48ca901 | 2009-08-11 21:38:54 | [diff] [blame] | 90 | static void CleanupOnIOThread(); |
91 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 92 | void CreateFileThread(); |
93 | void CreateDBThread(); | ||||
[email protected] | 91451171 | 2009-11-23 19:42:33 | [diff] [blame] | 94 | void CreateProcessLauncherThread(); |
[email protected] | 875ee82 | 2010-05-18 20:58:01 | [diff] [blame] | 95 | void CreateCacheThread(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 96 | void CreateTemplateURLModel(); |
97 | void CreateProfileManager(); | ||||
98 | void CreateWebDataService(); | ||||
99 | void CreateLocalState(); | ||||
100 | void CreateViewedPageTracker(); | ||||
101 | void CreateIconManager(); | ||||
[email protected] | a9bf6798 | 2010-07-06 10:13:00 | [diff] [blame] | 102 | void CreateDebuggerWrapper(int port, bool useHttp); |
[email protected] | 40ecc90 | 2009-03-16 13:42:47 | [diff] [blame] | 103 | void CreateDevToolsManager(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 104 | void CreateGoogleURLTracker(); |
[email protected] | c4ff495 | 2010-01-08 19:12:47 | [diff] [blame] | 105 | void CreateIntranetRedirectDetector(); |
[email protected] | 29672ab | 2009-10-30 03:44:03 | [diff] [blame] | 106 | void CreateNotificationUIManager(); |
[email protected] | ccb55cf5 | 2010-03-06 22:02:04 | [diff] [blame] | 107 | void CreateStatusTrayManager(); |
[email protected] | 0b4d338 | 2010-07-14 16:13:04 | [diff] [blame] | 108 | void CreateTabCloseableStateWatcher(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 109 | |
[email protected] | d55aaa13 | 2009-09-28 21:08:04 | [diff] [blame] | 110 | #if defined(IPC_MESSAGE_LOG_ENABLED) |
111 | void SetIPCLoggingEnabledForChildProcesses(bool enabled); | ||||
112 | #endif | ||||
113 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 114 | bool created_resource_dispatcher_host_; |
115 | scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_; | ||||
116 | |||||
117 | bool created_metrics_service_; | ||||
118 | scoped_ptr<MetricsService> metrics_service_; | ||||
119 | |||||
120 | bool created_io_thread_; | ||||
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 121 | scoped_ptr<IOThread> io_thread_; |
[email protected] | 25d47c7b | 2010-02-03 20:13:06 | [diff] [blame] | 122 | #if defined(USE_X11) |
[email protected] | 4c3cd741 | 2009-04-22 17:56:06 | [diff] [blame] | 123 | // This shares a created flag with the IO thread. |
124 | scoped_ptr<base::Thread> background_x11_thread_; | ||||
125 | #endif | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 126 | |
127 | bool created_file_thread_; | ||||
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 128 | scoped_ptr<base::Thread> file_thread_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 129 | |
130 | bool created_db_thread_; | ||||
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 131 | scoped_ptr<base::Thread> db_thread_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 132 | |
[email protected] | 91451171 | 2009-11-23 19:42:33 | [diff] [blame] | 133 | bool created_process_launcher_thread_; |
134 | scoped_ptr<base::Thread> process_launcher_thread_; | ||||
135 | |||||
[email protected] | 875ee82 | 2010-05-18 20:58:01 | [diff] [blame] | 136 | bool created_cache_thread_; |
137 | scoped_ptr<base::Thread> cache_thread_; | ||||
138 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 139 | bool created_profile_manager_; |
140 | scoped_ptr<ProfileManager> profile_manager_; | ||||
141 | |||||
142 | bool created_local_state_; | ||||
143 | scoped_ptr<PrefService> local_state_; | ||||
144 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 145 | bool created_icon_manager_; |
146 | scoped_ptr<IconManager> icon_manager_; | ||||
147 | |||||
148 | bool created_debugger_wrapper_; | ||||
149 | scoped_refptr<DebuggerWrapper> debugger_wrapper_; | ||||
150 | |||||
[email protected] | 40ecc90 | 2009-03-16 13:42:47 | [diff] [blame] | 151 | bool created_devtools_manager_; |
[email protected] | 73ee0152 | 2009-06-05 10:13:44 | [diff] [blame] | 152 | scoped_refptr<DevToolsManager> devtools_manager_; |
[email protected] | 40ecc90 | 2009-03-16 13:42:47 | [diff] [blame] | 153 | |
[email protected] | 1b8d02f1 | 2009-05-05 04:14:11 | [diff] [blame] | 154 | scoped_ptr<Clipboard> clipboard_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 155 | |
[email protected] | 29672ab | 2009-10-30 03:44:03 | [diff] [blame] | 156 | // Manager for desktop notification UI. |
157 | bool created_notification_ui_manager_; | ||||
158 | scoped_ptr<NotificationUIManager> notification_ui_manager_; | ||||
159 | |||||
[email protected] | ccb55cf5 | 2010-03-06 22:02:04 | [diff] [blame] | 160 | // Manager for status tray. |
161 | scoped_ptr<StatusTrayManager> status_tray_manager_; | ||||
162 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 163 | scoped_ptr<AutomationProviderList> automation_provider_list_; |
164 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 165 | scoped_ptr<GoogleURLTracker> google_url_tracker_; |
[email protected] | c4ff495 | 2010-01-08 19:12:47 | [diff] [blame] | 166 | scoped_ptr<IntranetRedirectDetector> intranet_redirect_detector_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 167 | |
168 | scoped_ptr<NotificationService> main_notification_service_; | ||||
169 | |||||
[email protected] | 0b4d338 | 2010-07-14 16:13:04 | [diff] [blame] | 170 | scoped_ptr<TabCloseableStateWatcher> tab_closeable_state_watcher_; |
171 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 172 | unsigned int module_ref_count_; |
[email protected] | afd20c02 | 2010-06-10 00:48:20 | [diff] [blame] | 173 | bool did_start_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 174 | |
175 | // Ensures that all the print jobs are finished before closing the browser. | ||||
176 | scoped_ptr<printing::PrintJobManager> print_job_manager_; | ||||
177 | |||||
[email protected] | d70539de | 2009-06-24 22:17:06 | [diff] [blame] | 178 | std::string locale_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 179 | |
[email protected] | 1b2db1a | 2008-08-08 17:46:13 | [diff] [blame] | 180 | bool checked_for_new_frames_; |
181 | bool using_new_frames_; | ||||
182 | |||||
[email protected] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 183 | // This service just sits around and makes thumanails for tabs. It does |
184 | // nothing in the cosntructor so we don't have to worry about lazy init. | ||||
[email protected] | 67a46b7f | 2009-06-16 21:41:02 | [diff] [blame] | 185 | ThumbnailGenerator thumbnail_generator_; |
[email protected] | 67a46b7f | 2009-06-16 21:41:02 | [diff] [blame] | 186 | |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 187 | // An event that notifies when we are shutting-down. |
[email protected] | b797e15 | 2009-01-23 16:06:14 | [diff] [blame] | 188 | scoped_ptr<base::WaitableEvent> shutdown_event_; |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 189 | |
[email protected] | 6641bf66 | 2009-08-21 00:34:09 | [diff] [blame] | 190 | // Runs on the file thread and stats the inspector's directory, filling in |
191 | // have_inspector_files_ with the result. | ||||
192 | void DoInspectorFilesCheck(); | ||||
193 | // Our best estimate about the existence of the inspector directory. | ||||
194 | bool have_inspector_files_; | ||||
195 | |||||
[email protected] | 3cdacd4 | 2010-04-30 18:55:53 | [diff] [blame] | 196 | #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 197 | base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_; |
198 | |||||
199 | // Gets called by autoupdate timer to see if browser needs restart and can be | ||||
200 | // restarted, and if that's the case, restarts the browser. | ||||
201 | void OnAutoupdateTimer(); | ||||
202 | bool CanAutorestartForUpdate() const; | ||||
203 | void RestartPersistentInstance(); | ||||
[email protected] | 3cdacd4 | 2010-04-30 18:55:53 | [diff] [blame] | 204 | #endif // defined(OS_WIN) || defined(OS_LINUX) |
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 205 | |
[email protected] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 206 | DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 207 | }; |
208 | |||||
[email protected] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 209 | #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ |