blob: b26127d3e8cbd70072b1e3c740dd51632f9d5022 [file] [log] [blame]
[email protected]c4ff4952010-01-08 19:12:471// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
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]58dca552009-06-17 00:35:0210#ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
11#define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
[email protected]32b76ef2010-07-26 23:08:2412#pragma once
initial.commit09911bf2008-07-26 23:55:2913
14#include <string>
15
16#include "base/basictypes.h"
17#include "base/message_loop.h"
18#include "base/non_thread_safe.h"
[email protected]bd48c2b02010-04-09 20:32:4219#include "base/timer.h"
initial.commit09911bf2008-07-26 23:55:2920#include "base/scoped_ptr.h"
initial.commit09911bf2008-07-26 23:55:2921#include "chrome/browser/browser_process.h"
[email protected]67a46b7f2009-06-16 21:41:0222#include "chrome/browser/tab_contents/thumbnail_generator.h"
[email protected]d55aaa132009-09-28 21:08:0423#include "ipc/ipc_message.h"
[email protected]b112a4c2009-02-01 20:24:0124
initial.commit09911bf2008-07-26 23:55:2925class CommandLine;
[email protected]a9bf67982010-07-06 10:13:0026class DebuggerWrapper;
[email protected]4ef795df2010-02-03 02:35:0827class FilePath;
initial.commit09911bf2008-07-26 23:55:2928class NotificationService;
[email protected]0b4d3382010-07-14 16:13:0429class TabCloseableStateWatcher;
initial.commit09911bf2008-07-26 23:55:2930
31// Real implementation of BrowserProcess that creates and returns the services.
32class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
33 public:
[email protected]f3a4f302009-08-21 22:35:2934 explicit BrowserProcessImpl(const CommandLine& command_line);
initial.commit09911bf2008-07-26 23:55:2935 virtual ~BrowserProcessImpl();
36
37 virtual void EndSession();
38
[email protected]e13ad79b2010-07-22 21:36:5039 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]25d47c7b2010-02-03 20:13:0646#if defined(USE_X11)
[email protected]e13ad79b2010-07-22 21:36:5047 virtual base::Thread* background_x11_thread();
[email protected]4c3cd7412009-04-22 17:56:0648#endif
[email protected]e13ad79b2010-07-22 21:36:5049 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]b443cb042009-12-15 22:05:0959 virtual unsigned int AddRefModule();
[email protected]b443cb042009-12-15 22:05:0960 virtual unsigned int ReleaseModule();
[email protected]e13ad79b2010-07-22 21:36:5061 virtual bool IsShuttingDown();
initial.commit09911bf2008-07-26 23:55:2962 virtual printing::PrintJobManager* print_job_manager();
[email protected]e13ad79b2010-07-22 21:36:5063 virtual GoogleURLTracker* google_url_tracker();
64 virtual IntranetRedirectDetector* intranet_redirect_detector();
65 virtual const std::string& GetApplicationLocale();
[email protected]f1b6de22010-03-06 12:13:4766 virtual void SetApplicationLocale(const std::string& locale);
[email protected]e13ad79b2010-07-22 21:36:5067 virtual base::WaitableEvent* shutdown_event();
68 virtual TabCloseableStateWatcher* tab_closeable_state_watcher();
[email protected]6641bf662009-08-21 00:34:0969 virtual void CheckForInspectorFiles();
70
[email protected]3cdacd42010-04-30 18:55:5371#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
[email protected]bd48c2b02010-04-09 20:32:4272 void StartAutoupdateTimer();
[email protected]3cdacd42010-04-30 18:55:5373#endif
[email protected]bd48c2b02010-04-09 20:32:4274
[email protected]e13ad79b2010-07-22 21:36:5075 virtual bool have_inspector_files() const;
[email protected]6641bf662009-08-21 00:34:0976
[email protected]d55aaa132009-09-28 21:08:0477#if defined(IPC_MESSAGE_LOG_ENABLED)
78 virtual void SetIPCLoggingEnabled(bool enable);
79#endif
80
initial.commit09911bf2008-07-26 23:55:2981 private:
[email protected]4ef795df2010-02-03 02:35:0882 void ClearLocalState(const FilePath& profile_path);
83 bool ShouldClearLocalState(FilePath* profile_path);
84
initial.commit09911bf2008-07-26 23:55:2985 void CreateResourceDispatcherHost();
86 void CreatePrefService();
87 void CreateMetricsService();
[email protected]48ca9012009-08-11 21:38:5488
initial.commit09911bf2008-07-26 23:55:2989 void CreateIOThread();
[email protected]48ca9012009-08-11 21:38:5490 static void CleanupOnIOThread();
91
initial.commit09911bf2008-07-26 23:55:2992 void CreateFileThread();
93 void CreateDBThread();
[email protected]914511712009-11-23 19:42:3394 void CreateProcessLauncherThread();
[email protected]875ee822010-05-18 20:58:0195 void CreateCacheThread();
initial.commit09911bf2008-07-26 23:55:2996 void CreateTemplateURLModel();
97 void CreateProfileManager();
98 void CreateWebDataService();
99 void CreateLocalState();
100 void CreateViewedPageTracker();
101 void CreateIconManager();
[email protected]a9bf67982010-07-06 10:13:00102 void CreateDebuggerWrapper(int port, bool useHttp);
[email protected]40ecc902009-03-16 13:42:47103 void CreateDevToolsManager();
initial.commit09911bf2008-07-26 23:55:29104 void CreateGoogleURLTracker();
[email protected]c4ff4952010-01-08 19:12:47105 void CreateIntranetRedirectDetector();
[email protected]29672ab2009-10-30 03:44:03106 void CreateNotificationUIManager();
[email protected]ccb55cf52010-03-06 22:02:04107 void CreateStatusTrayManager();
[email protected]0b4d3382010-07-14 16:13:04108 void CreateTabCloseableStateWatcher();
initial.commit09911bf2008-07-26 23:55:29109
[email protected]d55aaa132009-09-28 21:08:04110#if defined(IPC_MESSAGE_LOG_ENABLED)
111 void SetIPCLoggingEnabledForChildProcesses(bool enabled);
112#endif
113
initial.commit09911bf2008-07-26 23:55:29114 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]0ac83682010-01-22 17:46:27121 scoped_ptr<IOThread> io_thread_;
[email protected]25d47c7b2010-02-03 20:13:06122#if defined(USE_X11)
[email protected]4c3cd7412009-04-22 17:56:06123 // This shares a created flag with the IO thread.
124 scoped_ptr<base::Thread> background_x11_thread_;
125#endif
initial.commit09911bf2008-07-26 23:55:29126
127 bool created_file_thread_;
[email protected]ab820df2008-08-26 05:55:10128 scoped_ptr<base::Thread> file_thread_;
initial.commit09911bf2008-07-26 23:55:29129
130 bool created_db_thread_;
[email protected]ab820df2008-08-26 05:55:10131 scoped_ptr<base::Thread> db_thread_;
initial.commit09911bf2008-07-26 23:55:29132
[email protected]914511712009-11-23 19:42:33133 bool created_process_launcher_thread_;
134 scoped_ptr<base::Thread> process_launcher_thread_;
135
[email protected]875ee822010-05-18 20:58:01136 bool created_cache_thread_;
137 scoped_ptr<base::Thread> cache_thread_;
138
initial.commit09911bf2008-07-26 23:55:29139 bool created_profile_manager_;
140 scoped_ptr<ProfileManager> profile_manager_;
141
142 bool created_local_state_;
143 scoped_ptr<PrefService> local_state_;
144
initial.commit09911bf2008-07-26 23:55:29145 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]40ecc902009-03-16 13:42:47151 bool created_devtools_manager_;
[email protected]73ee01522009-06-05 10:13:44152 scoped_refptr<DevToolsManager> devtools_manager_;
[email protected]40ecc902009-03-16 13:42:47153
[email protected]1b8d02f12009-05-05 04:14:11154 scoped_ptr<Clipboard> clipboard_;
initial.commit09911bf2008-07-26 23:55:29155
[email protected]29672ab2009-10-30 03:44:03156 // Manager for desktop notification UI.
157 bool created_notification_ui_manager_;
158 scoped_ptr<NotificationUIManager> notification_ui_manager_;
159
[email protected]ccb55cf52010-03-06 22:02:04160 // Manager for status tray.
161 scoped_ptr<StatusTrayManager> status_tray_manager_;
162
initial.commit09911bf2008-07-26 23:55:29163 scoped_ptr<AutomationProviderList> automation_provider_list_;
164
initial.commit09911bf2008-07-26 23:55:29165 scoped_ptr<GoogleURLTracker> google_url_tracker_;
[email protected]c4ff4952010-01-08 19:12:47166 scoped_ptr<IntranetRedirectDetector> intranet_redirect_detector_;
initial.commit09911bf2008-07-26 23:55:29167
168 scoped_ptr<NotificationService> main_notification_service_;
169
[email protected]0b4d3382010-07-14 16:13:04170 scoped_ptr<TabCloseableStateWatcher> tab_closeable_state_watcher_;
171
initial.commit09911bf2008-07-26 23:55:29172 unsigned int module_ref_count_;
[email protected]afd20c022010-06-10 00:48:20173 bool did_start_;
initial.commit09911bf2008-07-26 23:55:29174
175 // Ensures that all the print jobs are finished before closing the browser.
176 scoped_ptr<printing::PrintJobManager> print_job_manager_;
177
[email protected]d70539de2009-06-24 22:17:06178 std::string locale_;
initial.commit09911bf2008-07-26 23:55:29179
[email protected]1b2db1a2008-08-08 17:46:13180 bool checked_for_new_frames_;
181 bool using_new_frames_;
182
[email protected]58dca552009-06-17 00:35:02183 // 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]67a46b7f2009-06-16 21:41:02185 ThumbnailGenerator thumbnail_generator_;
[email protected]67a46b7f2009-06-16 21:41:02186
[email protected]d65cab7a2008-08-12 01:25:41187 // An event that notifies when we are shutting-down.
[email protected]b797e152009-01-23 16:06:14188 scoped_ptr<base::WaitableEvent> shutdown_event_;
[email protected]d65cab7a2008-08-12 01:25:41189
[email protected]6641bf662009-08-21 00:34:09190 // 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]3cdacd42010-04-30 18:55:53196#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
[email protected]bd48c2b02010-04-09 20:32:42197 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]3cdacd42010-04-30 18:55:53204#endif // defined(OS_WIN) || defined(OS_LINUX)
[email protected]bd48c2b02010-04-09 20:32:42205
[email protected]58dca552009-06-17 00:35:02206 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
initial.commit09911bf2008-07-26 23:55:29207};
208
[email protected]58dca552009-06-17 00:35:02209#endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_