blob: f58357ba38bdaea610d4d13b2e63f342f980e350 [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#include "chrome/browser/browser_process_impl.h"
6
[email protected]90f39902009-10-03 04:25:377#include "app/clipboard/clipboard.h"
[email protected]a92b8642009-05-05 23:38:568#include "app/l10n_util.h"
initial.commit09911bf2008-07-26 23:55:299#include "base/command_line.h"
[email protected]6641bf662009-08-21 00:34:0910#include "base/file_util.h"
initial.commit09911bf2008-07-26 23:55:2911#include "base/path_service.h"
[email protected]ac262c9f2008-10-19 17:45:2112#include "base/thread.h"
[email protected]1c4947f2009-01-15 22:25:1113#include "base/waitable_event.h"
[email protected]b443cb042009-12-15 22:05:0914#include "chrome/browser/browser_main.h"
[email protected]0ac83682010-01-22 17:46:2715#include "chrome/browser/browser_process_sub_thread.h"
[email protected]ac262c9f2008-10-19 17:45:2116#include "chrome/browser/browser_trial.h"
initial.commit09911bf2008-07-26 23:55:2917#include "chrome/browser/chrome_thread.h"
[email protected]4ab4b0f2009-02-10 18:54:5018#include "chrome/browser/debugger/debugger_wrapper.h"
[email protected]40ecc902009-03-16 13:42:4719#include "chrome/browser/debugger/devtools_manager.h"
[email protected]b7f05882009-02-22 01:21:5620#include "chrome/browser/download/download_file.h"
[email protected]5ba0a2c2009-02-19 01:19:3421#include "chrome/browser/download/save_file_manager.h"
initial.commit09911bf2008-07-26 23:55:2922#include "chrome/browser/google_url_tracker.h"
[email protected]dcefa302009-05-20 00:24:3923#include "chrome/browser/icon_manager.h"
[email protected]4ef795df2010-02-03 02:35:0824#include "chrome/browser/in_process_webkit/dom_storage_context.h"
[email protected]c4ff4952010-01-08 19:12:4725#include "chrome/browser/intranet_redirect_detector.h"
[email protected]0ac83682010-01-22 17:46:2726#include "chrome/browser/io_thread.h"
[email protected]dc6f4962009-02-13 01:25:5027#include "chrome/browser/metrics/metrics_service.h"
[email protected]1933eb202009-02-19 18:23:2528#include "chrome/browser/net/dns_global.h"
[email protected]d393a0fd2009-05-13 23:32:0129#include "chrome/browser/net/sdch_dictionary_fetcher.h"
[email protected]4ef795df2010-02-03 02:35:0830#include "chrome/browser/net/sqlite_persistent_cookie_store.h"
[email protected]29672ab2009-10-30 03:44:0331#include "chrome/browser/notifications/notification_ui_manager.h"
[email protected]fd49e2d2009-02-20 17:21:3032#include "chrome/browser/plugin_service.h"
initial.commit09911bf2008-07-26 23:55:2933#include "chrome/browser/profile_manager.h"
[email protected]8c8657d62009-01-16 18:31:2634#include "chrome/browser/renderer_host/render_process_host.h"
[email protected]81218f42009-02-05 18:48:0835#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
36#include "chrome/browser/safe_browsing/safe_browsing_service.h"
[email protected]b1748b1d82009-11-30 20:32:5637#include "chrome/common/child_process_host.h"
[email protected]4ef795df2010-02-03 02:35:0838#include "chrome/common/chrome_constants.h"
initial.commit09911bf2008-07-26 23:55:2939#include "chrome/common/chrome_paths.h"
40#include "chrome/common/chrome_switches.h"
initial.commit09911bf2008-07-26 23:55:2941#include "chrome/common/notification_service.h"
42#include "chrome/common/pref_names.h"
43#include "chrome/common/pref_service.h"
[email protected]4ef795df2010-02-03 02:35:0844#include "chrome/common/url_constants.h"
[email protected]d55aaa132009-09-28 21:08:0445#include "ipc/ipc_logging.h"
[email protected]4ef795df2010-02-03 02:35:0846#include "webkit/database/database_tracker.h"
[email protected]b112a4c2009-02-01 20:24:0147
48#if defined(OS_WIN)
[email protected]2362e4f2009-05-08 00:34:0549#include "views/focus/view_storage.h"
[email protected]86230b92009-11-23 20:38:3850#endif
51
52#if defined(OS_LINUX)
53// TODO(port): get rid of this.
[email protected]81218f42009-02-05 18:48:0854#include "chrome/common/temp_scaffolding_stubs.h"
[email protected]86230b92009-11-23 20:38:3855#else
56#include "chrome/browser/printing/print_job_manager.h"
[email protected]b112a4c2009-02-01 20:24:0157#endif
initial.commit09911bf2008-07-26 23:55:2958
[email protected]d55aaa132009-09-28 21:08:0459#if defined(IPC_MESSAGE_LOG_ENABLED)
60#include "chrome/common/plugin_messages.h"
61#include "chrome/common/render_messages.h"
62#endif
63
[email protected]bb975362009-01-21 01:00:2264BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
initial.commit09911bf2008-07-26 23:55:2965 : created_resource_dispatcher_host_(false),
66 created_metrics_service_(false),
67 created_io_thread_(false),
68 created_file_thread_(false),
69 created_db_thread_(false),
[email protected]914511712009-11-23 19:42:3370 created_process_launcher_thread_(false),
initial.commit09911bf2008-07-26 23:55:2971 created_profile_manager_(false),
72 created_local_state_(false),
[email protected]f3a4f302009-08-21 22:35:2973#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:2974 initialized_broker_services_(false),
initial.commit09911bf2008-07-26 23:55:2975 broker_services_(NULL),
[email protected]f3a4f302009-08-21 22:35:2976#endif // defined(OS_WIN)
[email protected]b112a4c2009-02-01 20:24:0177 created_icon_manager_(false),
78 created_debugger_wrapper_(false),
[email protected]40ecc902009-03-16 13:42:4779 created_devtools_manager_(false),
[email protected]29672ab2009-10-30 03:44:0380 created_notification_ui_manager_(false),
initial.commit09911bf2008-07-26 23:55:2981 module_ref_count_(0),
[email protected]1b2db1a2008-08-08 17:46:1382 checked_for_new_frames_(false),
[email protected]6641bf662009-08-21 00:34:0983 using_new_frames_(false),
84 have_inspector_files_(true) {
initial.commit09911bf2008-07-26 23:55:2985 g_browser_process = this;
[email protected]1b8d02f12009-05-05 04:14:1186 clipboard_.reset(new Clipboard);
initial.commit09911bf2008-07-26 23:55:2987 main_notification_service_.reset(new NotificationService);
88
89 // Must be created after the NotificationService.
90 print_job_manager_.reset(new printing::PrintJobManager);
91
[email protected]b797e152009-01-23 16:06:1492 shutdown_event_.reset(new base::WaitableEvent(true, false));
initial.commit09911bf2008-07-26 23:55:2993}
94
95BrowserProcessImpl::~BrowserProcessImpl() {
[email protected]4ef795df2010-02-03 02:35:0896 FilePath profile_path;
97 bool clear_local_state_on_exit;
98
99 // Store the profile path for clearing local state data on exit.
100 clear_local_state_on_exit = ShouldClearLocalState(&profile_path);
101
initial.commit09911bf2008-07-26 23:55:29102 // Delete the AutomationProviderList before NotificationService,
103 // since it may try to unregister notifications
104 // Both NotificationService and AutomationProvider are singleton instances in
105 // the BrowserProcess. Since AutomationProvider may have some active
106 // notification observers, it is essential that it gets destroyed before the
107 // NotificationService. NotificationService won't be destroyed until after
108 // this destructor is run.
109 automation_provider_list_.reset();
110
[email protected]d393a0fd2009-05-13 23:32:01111 // We need to shutdown the SdchDictionaryFetcher as it regularly holds
112 // a pointer to a URLFetcher, and that URLFetcher (upon destruction) will do
113 // a PostDelayedTask onto the IO thread. This shutdown call will both discard
114 // any pending URLFetchers, and avoid creating any more.
115 SdchDictionaryFetcher::Shutdown();
116
[email protected]c4ff4952010-01-08 19:12:47117 // We need to destroy the MetricsService, GoogleURLTracker, and
118 // IntranetRedirectDetector before the io_thread_ gets destroyed, since their
119 // destructors can call the URLFetcher destructor, which does a
120 // PostDelayedTask operation on the IO thread. (The IO thread will handle
121 // that URLFetcher operation before going away.)
initial.commit09911bf2008-07-26 23:55:29122 metrics_service_.reset();
123 google_url_tracker_.reset();
[email protected]c4ff4952010-01-08 19:12:47124 intranet_redirect_detector_.reset();
initial.commit09911bf2008-07-26 23:55:29125
126 // Need to clear profiles (download managers) before the io_thread_.
127 profile_manager_.reset();
128
129 // Debugger must be cleaned up before IO thread and NotificationService.
130 debugger_wrapper_ = NULL;
131
132 if (resource_dispatcher_host_.get()) {
133 // Need to tell Safe Browsing Service that the IO thread is going away
134 // since it cached a pointer to it.
135 if (resource_dispatcher_host()->safe_browsing_service())
136 resource_dispatcher_host()->safe_browsing_service()->ShutDown();
137
138 // Cancel pending requests and prevent new requests.
139 resource_dispatcher_host()->Shutdown();
140 }
141
[email protected]4c3cd7412009-04-22 17:56:06142#if defined(OS_LINUX)
143 // The IO thread must outlive the BACKGROUND_X11 thread.
144 background_x11_thread_.reset();
145#endif
146
initial.commit09911bf2008-07-26 23:55:29147 // Need to stop io_thread_ before resource_dispatcher_host_, since
148 // io_thread_ may still deref ResourceDispatcherHost and handle resource
149 // request before going away.
[email protected]0ac83682010-01-22 17:46:27150 io_thread_.reset();
initial.commit09911bf2008-07-26 23:55:29151
[email protected]914511712009-11-23 19:42:33152 // Stop the process launcher thread after the IO thread, in case the IO thread
153 // posted a task to terminate a process on the process launcher thread.
154 process_launcher_thread_.reset();
155
initial.commit09911bf2008-07-26 23:55:29156 // Clean up state that lives on the file_thread_ before it goes away.
157 if (resource_dispatcher_host_.get()) {
158 resource_dispatcher_host()->download_file_manager()->Shutdown();
159 resource_dispatcher_host()->save_file_manager()->Shutdown();
160 }
161
162 // Need to stop the file_thread_ here to force it to process messages in its
163 // message loop from the previous call to shutdown the DownloadFileManager,
164 // SaveFileManager and SessionService.
165 file_thread_.reset();
166
[email protected]4ef795df2010-02-03 02:35:08167 // At this point, no render process exist, so it's safe to access local
168 // state data such as cookies, database, or local storage.
169 if (clear_local_state_on_exit)
170 ClearLocalState(profile_path);
171
initial.commit09911bf2008-07-26 23:55:29172 // With the file_thread_ flushed, we can release any icon resources.
173 icon_manager_.reset();
174
175 // Need to destroy ResourceDispatcherHost before PluginService and
176 // SafeBrowsingService, since it caches a pointer to it.
177 resource_dispatcher_host_.reset();
178
179 // Wait for the pending print jobs to finish.
180 print_job_manager_->OnQuit();
181 print_job_manager_.reset();
182
initial.commit09911bf2008-07-26 23:55:29183 // Now OK to destroy NotificationService.
184 main_notification_service_.reset();
185
186 g_browser_process = NULL;
187}
188
[email protected]295039bd2008-08-15 04:32:57189// Send a QuitTask to the given MessageLoop.
190static void PostQuit(MessageLoop* message_loop) {
191 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
192}
initial.commit09911bf2008-07-26 23:55:29193
[email protected]b443cb042009-12-15 22:05:09194unsigned int BrowserProcessImpl::AddRefModule() {
195 DCHECK(CalledOnValidThread());
196 module_ref_count_++;
197 return module_ref_count_;
198}
199
200unsigned int BrowserProcessImpl::ReleaseModule() {
201 DCHECK(CalledOnValidThread());
202 DCHECK(0 != module_ref_count_);
203 module_ref_count_--;
204 if (0 == module_ref_count_) {
205 MessageLoop::current()->PostTask(
206 FROM_HERE, NewRunnableFunction(Platform::DidEndMainMessageLoop));
207 MessageLoop::current()->Quit();
208 }
209 return module_ref_count_;
210}
211
initial.commit09911bf2008-07-26 23:55:29212void BrowserProcessImpl::EndSession() {
[email protected]b112a4c2009-02-01 20:24:01213#if defined(OS_WIN)
[email protected]d65cab7a2008-08-12 01:25:41214 // Notify we are going away.
[email protected]b797e152009-01-23 16:06:14215 ::SetEvent(shutdown_event_->handle());
[email protected]b112a4c2009-02-01 20:24:01216#endif
[email protected]d65cab7a2008-08-12 01:25:41217
initial.commit09911bf2008-07-26 23:55:29218 // Mark all the profiles as clean.
219 ProfileManager* pm = profile_manager();
220 for (ProfileManager::const_iterator i = pm->begin(); i != pm->end(); ++i)
221 (*i)->MarkAsCleanShutdown();
222
223 // Tell the metrics service it was cleanly shutdown.
224 MetricsService* metrics = g_browser_process->metrics_service();
225 if (metrics && local_state()) {
226 metrics->RecordCleanShutdown();
227
228 metrics->RecordStartOfSessionEnd();
229
230 // MetricsService lazily writes to prefs, force it to write now.
[email protected]6faa0e0d2009-04-28 06:50:36231 local_state()->SavePersistentPrefs();
initial.commit09911bf2008-07-26 23:55:29232 }
233
234 // We must write that the profile and metrics service shutdown cleanly,
235 // otherwise on startup we'll think we crashed. So we block until done and
236 // then proceed with normal shutdown.
237 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
[email protected]295039bd2008-08-15 04:32:57238 NewRunnableFunction(PostQuit, MessageLoop::current()));
initial.commit09911bf2008-07-26 23:55:29239 MessageLoop::current()->Run();
240}
241
242printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
243 // TODO(abarth): DCHECK(CalledOnValidThread());
244 // See <http://b/1287209>.
245 // print_job_manager_ is initialized in the constructor and destroyed in the
246 // destructor, so it should always be valid.
247 DCHECK(print_job_manager_.get());
248 return print_job_manager_.get();
249}
250
[email protected]4ef795df2010-02-03 02:35:08251void BrowserProcessImpl::ClearLocalState(const FilePath& profile_path) {
252 SQLitePersistentCookieStore::ClearLocalState(profile_path.Append(
253 chrome::kCookieFilename));
254 DOMStorageContext::ClearLocalState(profile_path, chrome::kExtensionScheme);
255 webkit_database::DatabaseTracker::ClearLocalState(profile_path,
256 chrome::kExtensionScheme);
257 // TODO(jochen): clear app cache local state.
258}
259
260bool BrowserProcessImpl::ShouldClearLocalState(FilePath* profile_path) {
261 FilePath user_data_dir;
262 Profile* profile;
263
264 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
265 profile = profile_manager_->GetDefaultProfile(user_data_dir);
266 *profile_path = profile->GetPath();
267 return profile->GetPrefs()->GetBoolean(prefs::kClearSiteDataOnExit);
268}
269
initial.commit09911bf2008-07-26 23:55:29270void BrowserProcessImpl::CreateResourceDispatcherHost() {
271 DCHECK(!created_resource_dispatcher_host_ &&
272 resource_dispatcher_host_.get() == NULL);
273 created_resource_dispatcher_host_ = true;
274
[email protected]79084c2d2009-11-03 23:12:42275 resource_dispatcher_host_.reset(new ResourceDispatcherHost());
initial.commit09911bf2008-07-26 23:55:29276 resource_dispatcher_host_->Initialize();
277}
278
279void BrowserProcessImpl::CreateMetricsService() {
280 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL);
281 created_metrics_service_ = true;
282
283 metrics_service_.reset(new MetricsService);
284}
285
286void BrowserProcessImpl::CreateIOThread() {
287 DCHECK(!created_io_thread_ && io_thread_.get() == NULL);
288 created_io_thread_ = true;
289
290 // Prior to starting the io thread, we create the plugin service as
291 // it is predominantly used from the io thread, but must be created
292 // on the main thread. The service ctor is inexpensive and does not
293 // invoke the io_thread() accessor.
294 PluginService::GetInstance();
295
[email protected]4c3cd7412009-04-22 17:56:06296#if defined(OS_LINUX)
297 // The lifetime of the BACKGROUND_X11 thread is a subset of the IO thread so
298 // we start it now.
299 scoped_ptr<base::Thread> background_x11_thread(
300 new BrowserProcessSubThread(ChromeThread::BACKGROUND_X11));
301 if (!background_x11_thread->Start())
302 return;
303 background_x11_thread_.swap(background_x11_thread);
304#endif
305
[email protected]0ac83682010-01-22 17:46:27306 scoped_ptr<IOThread> thread(new IOThread);
[email protected]ab820df2008-08-26 05:55:10307 base::Thread::Options options;
308 options.message_loop_type = MessageLoop::TYPE_IO;
309 if (!thread->StartWithOptions(options))
initial.commit09911bf2008-07-26 23:55:29310 return;
311 io_thread_.swap(thread);
312}
313
314void BrowserProcessImpl::CreateFileThread() {
315 DCHECK(!created_file_thread_ && file_thread_.get() == NULL);
316 created_file_thread_ = true;
317
[email protected]ab820df2008-08-26 05:55:10318 scoped_ptr<base::Thread> thread(
319 new BrowserProcessSubThread(ChromeThread::FILE));
[email protected]a1db3842008-09-17 22:04:06320 base::Thread::Options options;
[email protected]9e549b582009-02-05 21:13:39321#if defined(OS_WIN)
322 // On Windows, the FILE thread needs to be have a UI message loop which pumps
323 // messages in such a way that Google Update can communicate back to us.
[email protected]a1db3842008-09-17 22:04:06324 options.message_loop_type = MessageLoop::TYPE_UI;
[email protected]9e549b582009-02-05 21:13:39325#else
326 options.message_loop_type = MessageLoop::TYPE_IO;
327#endif
[email protected]a1db3842008-09-17 22:04:06328 if (!thread->StartWithOptions(options))
initial.commit09911bf2008-07-26 23:55:29329 return;
330 file_thread_.swap(thread);
331}
332
333void BrowserProcessImpl::CreateDBThread() {
334 DCHECK(!created_db_thread_ && db_thread_.get() == NULL);
335 created_db_thread_ = true;
336
[email protected]ab820df2008-08-26 05:55:10337 scoped_ptr<base::Thread> thread(
338 new BrowserProcessSubThread(ChromeThread::DB));
initial.commit09911bf2008-07-26 23:55:29339 if (!thread->Start())
340 return;
341 db_thread_.swap(thread);
342}
343
[email protected]914511712009-11-23 19:42:33344void BrowserProcessImpl::CreateProcessLauncherThread() {
345 DCHECK(!created_process_launcher_thread_ && !process_launcher_thread_.get());
346 created_process_launcher_thread_ = true;
347
348 scoped_ptr<base::Thread> thread(
349 new BrowserProcessSubThread(ChromeThread::PROCESS_LAUNCHER));
350 if (!thread->Start())
351 return;
352 process_launcher_thread_.swap(thread);
353}
354
initial.commit09911bf2008-07-26 23:55:29355void BrowserProcessImpl::CreateProfileManager() {
356 DCHECK(!created_profile_manager_ && profile_manager_.get() == NULL);
357 created_profile_manager_ = true;
358
359 profile_manager_.reset(new ProfileManager());
360}
361
362void BrowserProcessImpl::CreateLocalState() {
363 DCHECK(!created_local_state_ && local_state_.get() == NULL);
364 created_local_state_ = true;
365
[email protected]b9636002009-03-04 00:05:25366 FilePath local_state_path;
initial.commit09911bf2008-07-26 23:55:29367 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
[email protected]6fad2632009-11-02 05:59:37368 local_state_.reset(new PrefService(local_state_path));
initial.commit09911bf2008-07-26 23:55:29369}
370
[email protected]f3a4f302009-08-21 22:35:29371#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29372void BrowserProcessImpl::InitBrokerServices(
373 sandbox::BrokerServices* broker_services) {
374 DCHECK(!initialized_broker_services_ && broker_services_ == NULL);
375 broker_services->Init();
376 initialized_broker_services_ = true;
377 broker_services_ = broker_services;
378}
[email protected]f3a4f302009-08-21 22:35:29379#endif // defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29380
381void BrowserProcessImpl::CreateIconManager() {
382 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL);
383 created_icon_manager_ = true;
384 icon_manager_.reset(new IconManager);
385}
386
387void BrowserProcessImpl::CreateDebuggerWrapper(int port) {
388 DCHECK(debugger_wrapper_.get() == NULL);
389 created_debugger_wrapper_ = true;
390
391 debugger_wrapper_ = new DebuggerWrapper(port);
392}
393
[email protected]40ecc902009-03-16 13:42:47394void BrowserProcessImpl::CreateDevToolsManager() {
[email protected]73ee01522009-06-05 10:13:44395 DCHECK(devtools_manager_.get() == NULL);
[email protected]40ecc902009-03-16 13:42:47396 created_devtools_manager_ = true;
[email protected]73ee01522009-06-05 10:13:44397 devtools_manager_ = new DevToolsManager();
[email protected]40ecc902009-03-16 13:42:47398}
399
initial.commit09911bf2008-07-26 23:55:29400void BrowserProcessImpl::CreateGoogleURLTracker() {
401 DCHECK(google_url_tracker_.get() == NULL);
402 scoped_ptr<GoogleURLTracker> google_url_tracker(new GoogleURLTracker);
403 google_url_tracker_.swap(google_url_tracker);
404}
[email protected]6641bf662009-08-21 00:34:09405
[email protected]c4ff4952010-01-08 19:12:47406void BrowserProcessImpl::CreateIntranetRedirectDetector() {
407 DCHECK(intranet_redirect_detector_.get() == NULL);
408 scoped_ptr<IntranetRedirectDetector> intranet_redirect_detector(
409 new IntranetRedirectDetector);
410 intranet_redirect_detector_.swap(intranet_redirect_detector);
411}
412
[email protected]29672ab2009-10-30 03:44:03413void BrowserProcessImpl::CreateNotificationUIManager() {
414 DCHECK(notification_ui_manager_.get() == NULL);
415 notification_ui_manager_.reset(NotificationUIManager::Create());
416 created_notification_ui_manager_ = true;
417}
418
[email protected]6641bf662009-08-21 00:34:09419// The BrowserProcess object must outlive the file thread so we use traits
420// which don't do any management.
421template <>
422struct RunnableMethodTraits<BrowserProcessImpl> {
[email protected]ee5e3792009-10-13 23:23:47423 void RetainCallee(BrowserProcessImpl* process) {}
424 void ReleaseCallee(BrowserProcessImpl* process) {}
[email protected]6641bf662009-08-21 00:34:09425};
426
427void BrowserProcessImpl::CheckForInspectorFiles() {
428 file_thread()->message_loop()->PostTask
429 (FROM_HERE,
430 NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck));
431}
432
[email protected]d55aaa132009-09-28 21:08:04433#if defined(IPC_MESSAGE_LOG_ENABLED)
434
435void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) {
436 // First enable myself.
437 if (enable)
438 IPC::Logging::current()->Enable();
439 else
440 IPC::Logging::current()->Disable();
441
442 // Now tell subprocesses. Messages to ChildProcess-derived
443 // processes must be done on the IO thread.
444 io_thread()->message_loop()->PostTask
445 (FROM_HERE,
446 NewRunnableMethod(
447 this,
448 &BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses,
449 enable));
450
451 // Finally, tell the renderers which don't derive from ChildProcess.
452 // Messages to the renderers must be done on the UI (main) thread.
[email protected]019191a2009-10-02 20:37:27453 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
454 !i.IsAtEnd(); i.Advance())
455 i.GetCurrentValue()->Send(new ViewMsg_SetIPCLoggingEnabled(enable));
[email protected]d55aaa132009-09-28 21:08:04456}
457
458// Helper for SetIPCLoggingEnabled.
459void BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses(bool enabled) {
[email protected]d85cf072009-10-27 03:59:31460 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
[email protected]d55aaa132009-09-28 21:08:04461
462 ChildProcessHost::Iterator i; // default constr references a singleton
[email protected]34cf97d2009-09-29 22:46:11463 while (!i.Done()) {
464 i->Send(new PluginProcessMsg_SetIPCLoggingEnabled(enabled));
465 ++i;
[email protected]d55aaa132009-09-28 21:08:04466 }
467}
468
469#endif // IPC_MESSAGE_LOG_ENABLED
470
[email protected]6641bf662009-08-21 00:34:09471void BrowserProcessImpl::DoInspectorFilesCheck() {
472 // Runs on FILE thread.
473 DCHECK(file_thread_->message_loop() == MessageLoop::current());
474 bool result = false;
475
476 FilePath inspector_dir;
477 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) {
478 result = file_util::PathExists(inspector_dir);
479 }
480
[email protected]308080d2009-11-11 19:19:02481 have_inspector_files_ = result;
[email protected]6641bf662009-08-21 00:34:09482}