blob: af54bb5a5aa37af88568f3e79f819e3aa8f5ec8b [file] [log] [blame]
[email protected]019191a2009-10-02 20:37:271// Copyright (c) 2009 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]ac262c9f2008-10-19 17:45:2114#include "chrome/browser/browser_trial.h"
initial.commit09911bf2008-07-26 23:55:2915#include "chrome/browser/chrome_thread.h"
[email protected]4ab4b0f2009-02-10 18:54:5016#include "chrome/browser/debugger/debugger_wrapper.h"
[email protected]40ecc902009-03-16 13:42:4717#include "chrome/browser/debugger/devtools_manager.h"
[email protected]b7f05882009-02-22 01:21:5618#include "chrome/browser/download/download_file.h"
[email protected]5ba0a2c2009-02-19 01:19:3419#include "chrome/browser/download/save_file_manager.h"
initial.commit09911bf2008-07-26 23:55:2920#include "chrome/browser/google_url_tracker.h"
[email protected]dcefa302009-05-20 00:24:3921#include "chrome/browser/icon_manager.h"
[email protected]dc6f4962009-02-13 01:25:5022#include "chrome/browser/metrics/metrics_service.h"
[email protected]1933eb202009-02-19 18:23:2523#include "chrome/browser/net/dns_global.h"
[email protected]d393a0fd2009-05-13 23:32:0124#include "chrome/browser/net/sdch_dictionary_fetcher.h"
[email protected]29672ab2009-10-30 03:44:0325#include "chrome/browser/notifications/notification_ui_manager.h"
[email protected]fd49e2d2009-02-20 17:21:3026#include "chrome/browser/plugin_service.h"
initial.commit09911bf2008-07-26 23:55:2927#include "chrome/browser/profile_manager.h"
[email protected]8c8657d62009-01-16 18:31:2628#include "chrome/browser/renderer_host/render_process_host.h"
[email protected]81218f42009-02-05 18:48:0829#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
30#include "chrome/browser/safe_browsing/safe_browsing_service.h"
initial.commit09911bf2008-07-26 23:55:2931#include "chrome/common/chrome_paths.h"
32#include "chrome/common/chrome_switches.h"
initial.commit09911bf2008-07-26 23:55:2933#include "chrome/common/notification_service.h"
34#include "chrome/common/pref_names.h"
35#include "chrome/common/pref_service.h"
[email protected]d55aaa132009-09-28 21:08:0436#include "ipc/ipc_logging.h"
[email protected]b112a4c2009-02-01 20:24:0137
38#if defined(OS_WIN)
39#include "chrome/browser/automation/automation_provider_list.h"
[email protected]b112a4c2009-02-01 20:24:0140#include "chrome/browser/printing/print_job_manager.h"
[email protected]2362e4f2009-05-08 00:34:0541#include "views/focus/view_storage.h"
[email protected]b23aee0f2009-10-13 22:54:1242#elif defined(OS_MACOSX)
43#include "chrome/browser/printing/print_job_manager.h"
44#elif defined(OS_LINUX)
[email protected]81218f42009-02-05 18:48:0845// TODO(port): Remove the temporary scaffolding as we port the above headers.
46#include "chrome/common/temp_scaffolding_stubs.h"
[email protected]b112a4c2009-02-01 20:24:0147#endif
initial.commit09911bf2008-07-26 23:55:2948
[email protected]d55aaa132009-09-28 21:08:0449#if defined(IPC_MESSAGE_LOG_ENABLED)
50#include "chrome/common/plugin_messages.h"
51#include "chrome/common/render_messages.h"
52#endif
53
initial.commit09911bf2008-07-26 23:55:2954namespace {
55
56// ----------------------------------------------------------------------------
57// BrowserProcessSubThread
58//
59// This simple thread object is used for the specialized threads that the
60// BrowserProcess spins up.
61//
62// Applications must initialize the COM library before they can call
63// COM library functions other than CoGetMalloc and memory allocation
64// functions, so this class initializes COM for those users.
65class BrowserProcessSubThread : public ChromeThread {
66 public:
67 explicit BrowserProcessSubThread(ChromeThread::ID identifier)
68 : ChromeThread(identifier) {
69 }
70
[email protected]48ca9012009-08-11 21:38:5471 virtual ~BrowserProcessSubThread() {
initial.commit09911bf2008-07-26 23:55:2972 // We cannot rely on our base class to stop the thread since we want our
73 // CleanUp function to run.
74 Stop();
75 }
76
77 protected:
78 virtual void Init() {
[email protected]b112a4c2009-02-01 20:24:0179#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:2980 // Initializes the COM library on the current thread.
81 CoInitialize(NULL);
[email protected]b112a4c2009-02-01 20:24:0182#endif
initial.commit09911bf2008-07-26 23:55:2983
84 notification_service_ = new NotificationService;
85 }
86
87 virtual void CleanUp() {
88 delete notification_service_;
89 notification_service_ = NULL;
90
[email protected]b112a4c2009-02-01 20:24:0191#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:2992 // Closes the COM library on the current thread. CoInitialize must
93 // be balanced by a corresponding call to CoUninitialize.
94 CoUninitialize();
[email protected]b112a4c2009-02-01 20:24:0195#endif
initial.commit09911bf2008-07-26 23:55:2996 }
97
98 private:
99 // Each specialized thread has its own notification service.
100 // Note: We don't use scoped_ptr because the destructor runs on the wrong
101 // thread.
102 NotificationService* notification_service_;
103};
104
[email protected]48ca9012009-08-11 21:38:54105class IOThread : public BrowserProcessSubThread {
106 public:
107 IOThread() : BrowserProcessSubThread(ChromeThread::IO) {}
108
109 virtual ~IOThread() {
110 // We cannot rely on our base class to stop the thread since we want our
111 // CleanUp function to run.
112 Stop();
113 }
114
115 protected:
116 virtual void CleanUp() {
117 // URLFetcher and URLRequest instances must NOT outlive the IO thread.
[email protected]03a69dc2009-09-22 00:04:59118 //
119 // Strictly speaking, URLFetcher's CheckForLeaks() should be done on the
120 // UI thread. However, since there _shouldn't_ be any instances left
121 // at this point, it shouldn't be a race.
122 //
123 // We check URLFetcher first, since if it has leaked then an associated
124 // URLRequest will also have leaked. However it is more useful to
125 // crash showing the callstack of URLFetcher's allocation than its
126 // URLRequest member.
[email protected]48ca9012009-08-11 21:38:54127 base::LeakTracker<URLFetcher>::CheckForLeaks();
[email protected]03a69dc2009-09-22 00:04:59128 base::LeakTracker<URLRequest>::CheckForLeaks();
[email protected]48ca9012009-08-11 21:38:54129
130 BrowserProcessSubThread::CleanUp();
131 }
132};
133
initial.commit09911bf2008-07-26 23:55:29134} // namespace
135
[email protected]bb975362009-01-21 01:00:22136BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
initial.commit09911bf2008-07-26 23:55:29137 : created_resource_dispatcher_host_(false),
138 created_metrics_service_(false),
139 created_io_thread_(false),
140 created_file_thread_(false),
141 created_db_thread_(false),
142 created_profile_manager_(false),
143 created_local_state_(false),
[email protected]f3a4f302009-08-21 22:35:29144#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29145 initialized_broker_services_(false),
initial.commit09911bf2008-07-26 23:55:29146 broker_services_(NULL),
[email protected]f3a4f302009-08-21 22:35:29147#endif // defined(OS_WIN)
[email protected]b112a4c2009-02-01 20:24:01148 created_icon_manager_(false),
149 created_debugger_wrapper_(false),
[email protected]40ecc902009-03-16 13:42:47150 created_devtools_manager_(false),
[email protected]29672ab2009-10-30 03:44:03151 created_notification_ui_manager_(false),
initial.commit09911bf2008-07-26 23:55:29152 module_ref_count_(0),
[email protected]1b2db1a2008-08-08 17:46:13153 checked_for_new_frames_(false),
[email protected]6641bf662009-08-21 00:34:09154 using_new_frames_(false),
155 have_inspector_files_(true) {
initial.commit09911bf2008-07-26 23:55:29156 g_browser_process = this;
[email protected]1b8d02f12009-05-05 04:14:11157 clipboard_.reset(new Clipboard);
initial.commit09911bf2008-07-26 23:55:29158 main_notification_service_.reset(new NotificationService);
159
160 // Must be created after the NotificationService.
161 print_job_manager_.reset(new printing::PrintJobManager);
162
[email protected]b797e152009-01-23 16:06:14163 shutdown_event_.reset(new base::WaitableEvent(true, false));
initial.commit09911bf2008-07-26 23:55:29164}
165
166BrowserProcessImpl::~BrowserProcessImpl() {
167 // Delete the AutomationProviderList before NotificationService,
168 // since it may try to unregister notifications
169 // Both NotificationService and AutomationProvider are singleton instances in
170 // the BrowserProcess. Since AutomationProvider may have some active
171 // notification observers, it is essential that it gets destroyed before the
172 // NotificationService. NotificationService won't be destroyed until after
173 // this destructor is run.
174 automation_provider_list_.reset();
175
[email protected]d393a0fd2009-05-13 23:32:01176 // We need to shutdown the SdchDictionaryFetcher as it regularly holds
177 // a pointer to a URLFetcher, and that URLFetcher (upon destruction) will do
178 // a PostDelayedTask onto the IO thread. This shutdown call will both discard
179 // any pending URLFetchers, and avoid creating any more.
180 SdchDictionaryFetcher::Shutdown();
181
initial.commit09911bf2008-07-26 23:55:29182 // We need to destroy the MetricsService and GoogleURLTracker before the
183 // io_thread_ gets destroyed, since both destructors can call the URLFetcher
[email protected]d393a0fd2009-05-13 23:32:01184 // destructor, which does an PostDelayedTask operation on the IO thread. (The
185 // IO thread will handle that URLFetcher operation before going away.)
initial.commit09911bf2008-07-26 23:55:29186 metrics_service_.reset();
187 google_url_tracker_.reset();
188
189 // Need to clear profiles (download managers) before the io_thread_.
190 profile_manager_.reset();
191
192 // Debugger must be cleaned up before IO thread and NotificationService.
193 debugger_wrapper_ = NULL;
194
195 if (resource_dispatcher_host_.get()) {
196 // Need to tell Safe Browsing Service that the IO thread is going away
197 // since it cached a pointer to it.
198 if (resource_dispatcher_host()->safe_browsing_service())
199 resource_dispatcher_host()->safe_browsing_service()->ShutDown();
200
201 // Cancel pending requests and prevent new requests.
202 resource_dispatcher_host()->Shutdown();
203 }
204
[email protected]4c3cd7412009-04-22 17:56:06205#if defined(OS_LINUX)
206 // The IO thread must outlive the BACKGROUND_X11 thread.
207 background_x11_thread_.reset();
208#endif
209
initial.commit09911bf2008-07-26 23:55:29210 // Need to stop io_thread_ before resource_dispatcher_host_, since
211 // io_thread_ may still deref ResourceDispatcherHost and handle resource
212 // request before going away.
[email protected]48ca9012009-08-11 21:38:54213 ResetIOThread();
initial.commit09911bf2008-07-26 23:55:29214
215 // Clean up state that lives on the file_thread_ before it goes away.
216 if (resource_dispatcher_host_.get()) {
217 resource_dispatcher_host()->download_file_manager()->Shutdown();
218 resource_dispatcher_host()->save_file_manager()->Shutdown();
219 }
220
221 // Need to stop the file_thread_ here to force it to process messages in its
222 // message loop from the previous call to shutdown the DownloadFileManager,
223 // SaveFileManager and SessionService.
224 file_thread_.reset();
225
226 // With the file_thread_ flushed, we can release any icon resources.
227 icon_manager_.reset();
228
229 // Need to destroy ResourceDispatcherHost before PluginService and
230 // SafeBrowsingService, since it caches a pointer to it.
231 resource_dispatcher_host_.reset();
232
233 // Wait for the pending print jobs to finish.
234 print_job_manager_->OnQuit();
235 print_job_manager_.reset();
236
initial.commit09911bf2008-07-26 23:55:29237 // Now OK to destroy NotificationService.
238 main_notification_service_.reset();
239
240 g_browser_process = NULL;
241}
242
[email protected]295039bd2008-08-15 04:32:57243// Send a QuitTask to the given MessageLoop.
244static void PostQuit(MessageLoop* message_loop) {
245 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
246}
initial.commit09911bf2008-07-26 23:55:29247
248void BrowserProcessImpl::EndSession() {
[email protected]b112a4c2009-02-01 20:24:01249#if defined(OS_WIN)
[email protected]d65cab7a2008-08-12 01:25:41250 // Notify we are going away.
[email protected]b797e152009-01-23 16:06:14251 ::SetEvent(shutdown_event_->handle());
[email protected]b112a4c2009-02-01 20:24:01252#endif
[email protected]d65cab7a2008-08-12 01:25:41253
initial.commit09911bf2008-07-26 23:55:29254 // Mark all the profiles as clean.
255 ProfileManager* pm = profile_manager();
256 for (ProfileManager::const_iterator i = pm->begin(); i != pm->end(); ++i)
257 (*i)->MarkAsCleanShutdown();
258
259 // Tell the metrics service it was cleanly shutdown.
260 MetricsService* metrics = g_browser_process->metrics_service();
261 if (metrics && local_state()) {
262 metrics->RecordCleanShutdown();
263
264 metrics->RecordStartOfSessionEnd();
265
266 // MetricsService lazily writes to prefs, force it to write now.
[email protected]6faa0e0d2009-04-28 06:50:36267 local_state()->SavePersistentPrefs();
initial.commit09911bf2008-07-26 23:55:29268 }
269
270 // We must write that the profile and metrics service shutdown cleanly,
271 // otherwise on startup we'll think we crashed. So we block until done and
272 // then proceed with normal shutdown.
273 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
[email protected]295039bd2008-08-15 04:32:57274 NewRunnableFunction(PostQuit, MessageLoop::current()));
initial.commit09911bf2008-07-26 23:55:29275 MessageLoop::current()->Run();
276}
277
278printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
279 // TODO(abarth): DCHECK(CalledOnValidThread());
280 // See <http://b/1287209>.
281 // print_job_manager_ is initialized in the constructor and destroyed in the
282 // destructor, so it should always be valid.
283 DCHECK(print_job_manager_.get());
284 return print_job_manager_.get();
285}
286
[email protected]d70539de2009-06-24 22:17:06287const std::string& BrowserProcessImpl::GetApplicationLocale() {
initial.commit09911bf2008-07-26 23:55:29288 DCHECK(CalledOnValidThread());
289 if (locale_.empty()) {
[email protected]d70539de2009-06-24 22:17:06290 locale_ = l10n_util::GetApplicationLocale(
291 local_state()->GetString(prefs::kApplicationLocale));
initial.commit09911bf2008-07-26 23:55:29292 }
293 return locale_;
294}
295
296void BrowserProcessImpl::CreateResourceDispatcherHost() {
297 DCHECK(!created_resource_dispatcher_host_ &&
298 resource_dispatcher_host_.get() == NULL);
299 created_resource_dispatcher_host_ = true;
300
301 resource_dispatcher_host_.reset(
302 new ResourceDispatcherHost(io_thread()->message_loop()));
303 resource_dispatcher_host_->Initialize();
304}
305
306void BrowserProcessImpl::CreateMetricsService() {
307 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL);
308 created_metrics_service_ = true;
309
310 metrics_service_.reset(new MetricsService);
311}
312
313void BrowserProcessImpl::CreateIOThread() {
314 DCHECK(!created_io_thread_ && io_thread_.get() == NULL);
315 created_io_thread_ = true;
316
317 // Prior to starting the io thread, we create the plugin service as
318 // it is predominantly used from the io thread, but must be created
319 // on the main thread. The service ctor is inexpensive and does not
320 // invoke the io_thread() accessor.
321 PluginService::GetInstance();
322
[email protected]4c3cd7412009-04-22 17:56:06323#if defined(OS_LINUX)
324 // The lifetime of the BACKGROUND_X11 thread is a subset of the IO thread so
325 // we start it now.
326 scoped_ptr<base::Thread> background_x11_thread(
327 new BrowserProcessSubThread(ChromeThread::BACKGROUND_X11));
328 if (!background_x11_thread->Start())
329 return;
330 background_x11_thread_.swap(background_x11_thread);
331#endif
332
[email protected]48ca9012009-08-11 21:38:54333 scoped_ptr<base::Thread> thread(new IOThread);
[email protected]ab820df2008-08-26 05:55:10334 base::Thread::Options options;
335 options.message_loop_type = MessageLoop::TYPE_IO;
336 if (!thread->StartWithOptions(options))
initial.commit09911bf2008-07-26 23:55:29337 return;
338 io_thread_.swap(thread);
339}
340
[email protected]48ca9012009-08-11 21:38:54341void BrowserProcessImpl::ResetIOThread() {
342 if (io_thread_.get()) {
343 io_thread_->message_loop()->PostTask(FROM_HERE,
344 NewRunnableFunction(CleanupOnIOThread));
345 }
346 io_thread_.reset();
347}
348
349// static
350void BrowserProcessImpl::CleanupOnIOThread() {
351 // Shutdown DNS prefetching now to ensure that network stack objects
352 // living on the IO thread get destroyed before the IO thread goes away.
353 chrome_browser_net::EnsureDnsPrefetchShutdown();
354 // TODO(eroman): can this be merged into IOThread::CleanUp() ?
355}
356
initial.commit09911bf2008-07-26 23:55:29357void BrowserProcessImpl::CreateFileThread() {
358 DCHECK(!created_file_thread_ && file_thread_.get() == NULL);
359 created_file_thread_ = true;
360
[email protected]ab820df2008-08-26 05:55:10361 scoped_ptr<base::Thread> thread(
362 new BrowserProcessSubThread(ChromeThread::FILE));
[email protected]a1db3842008-09-17 22:04:06363 base::Thread::Options options;
[email protected]9e549b582009-02-05 21:13:39364#if defined(OS_WIN)
365 // On Windows, the FILE thread needs to be have a UI message loop which pumps
366 // messages in such a way that Google Update can communicate back to us.
[email protected]a1db3842008-09-17 22:04:06367 options.message_loop_type = MessageLoop::TYPE_UI;
[email protected]9e549b582009-02-05 21:13:39368#else
369 options.message_loop_type = MessageLoop::TYPE_IO;
370#endif
[email protected]a1db3842008-09-17 22:04:06371 if (!thread->StartWithOptions(options))
initial.commit09911bf2008-07-26 23:55:29372 return;
373 file_thread_.swap(thread);
374}
375
376void BrowserProcessImpl::CreateDBThread() {
377 DCHECK(!created_db_thread_ && db_thread_.get() == NULL);
378 created_db_thread_ = true;
379
[email protected]ab820df2008-08-26 05:55:10380 scoped_ptr<base::Thread> thread(
381 new BrowserProcessSubThread(ChromeThread::DB));
initial.commit09911bf2008-07-26 23:55:29382 if (!thread->Start())
383 return;
384 db_thread_.swap(thread);
385}
386
387void BrowserProcessImpl::CreateProfileManager() {
388 DCHECK(!created_profile_manager_ && profile_manager_.get() == NULL);
389 created_profile_manager_ = true;
390
391 profile_manager_.reset(new ProfileManager());
392}
393
394void BrowserProcessImpl::CreateLocalState() {
395 DCHECK(!created_local_state_ && local_state_.get() == NULL);
396 created_local_state_ = true;
397
[email protected]b9636002009-03-04 00:05:25398 FilePath local_state_path;
initial.commit09911bf2008-07-26 23:55:29399 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
[email protected]6fad2632009-11-02 05:59:37400 local_state_.reset(new PrefService(local_state_path));
initial.commit09911bf2008-07-26 23:55:29401}
402
[email protected]f3a4f302009-08-21 22:35:29403#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29404void BrowserProcessImpl::InitBrokerServices(
405 sandbox::BrokerServices* broker_services) {
406 DCHECK(!initialized_broker_services_ && broker_services_ == NULL);
407 broker_services->Init();
408 initialized_broker_services_ = true;
409 broker_services_ = broker_services;
410}
[email protected]f3a4f302009-08-21 22:35:29411#endif // defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29412
413void BrowserProcessImpl::CreateIconManager() {
414 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL);
415 created_icon_manager_ = true;
416 icon_manager_.reset(new IconManager);
417}
418
419void BrowserProcessImpl::CreateDebuggerWrapper(int port) {
420 DCHECK(debugger_wrapper_.get() == NULL);
421 created_debugger_wrapper_ = true;
422
423 debugger_wrapper_ = new DebuggerWrapper(port);
424}
425
[email protected]40ecc902009-03-16 13:42:47426void BrowserProcessImpl::CreateDevToolsManager() {
[email protected]73ee01522009-06-05 10:13:44427 DCHECK(devtools_manager_.get() == NULL);
[email protected]40ecc902009-03-16 13:42:47428 created_devtools_manager_ = true;
[email protected]73ee01522009-06-05 10:13:44429 devtools_manager_ = new DevToolsManager();
[email protected]40ecc902009-03-16 13:42:47430}
431
initial.commit09911bf2008-07-26 23:55:29432void BrowserProcessImpl::CreateGoogleURLTracker() {
433 DCHECK(google_url_tracker_.get() == NULL);
434 scoped_ptr<GoogleURLTracker> google_url_tracker(new GoogleURLTracker);
435 google_url_tracker_.swap(google_url_tracker);
436}
[email protected]6641bf662009-08-21 00:34:09437
[email protected]29672ab2009-10-30 03:44:03438void BrowserProcessImpl::CreateNotificationUIManager() {
439 DCHECK(notification_ui_manager_.get() == NULL);
440 notification_ui_manager_.reset(NotificationUIManager::Create());
441 created_notification_ui_manager_ = true;
442}
443
[email protected]6641bf662009-08-21 00:34:09444// The BrowserProcess object must outlive the file thread so we use traits
445// which don't do any management.
446template <>
447struct RunnableMethodTraits<BrowserProcessImpl> {
[email protected]ee5e3792009-10-13 23:23:47448 void RetainCallee(BrowserProcessImpl* process) {}
449 void ReleaseCallee(BrowserProcessImpl* process) {}
[email protected]6641bf662009-08-21 00:34:09450};
451
452void BrowserProcessImpl::CheckForInspectorFiles() {
453 file_thread()->message_loop()->PostTask
454 (FROM_HERE,
455 NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck));
456}
457
[email protected]d55aaa132009-09-28 21:08:04458#if defined(IPC_MESSAGE_LOG_ENABLED)
459
460void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) {
461 // First enable myself.
462 if (enable)
463 IPC::Logging::current()->Enable();
464 else
465 IPC::Logging::current()->Disable();
466
467 // Now tell subprocesses. Messages to ChildProcess-derived
468 // processes must be done on the IO thread.
469 io_thread()->message_loop()->PostTask
470 (FROM_HERE,
471 NewRunnableMethod(
472 this,
473 &BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses,
474 enable));
475
476 // Finally, tell the renderers which don't derive from ChildProcess.
477 // Messages to the renderers must be done on the UI (main) thread.
[email protected]019191a2009-10-02 20:37:27478 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
479 !i.IsAtEnd(); i.Advance())
480 i.GetCurrentValue()->Send(new ViewMsg_SetIPCLoggingEnabled(enable));
[email protected]d55aaa132009-09-28 21:08:04481}
482
483// Helper for SetIPCLoggingEnabled.
484void BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses(bool enabled) {
[email protected]d85cf072009-10-27 03:59:31485 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
[email protected]d55aaa132009-09-28 21:08:04486
487 ChildProcessHost::Iterator i; // default constr references a singleton
[email protected]34cf97d2009-09-29 22:46:11488 while (!i.Done()) {
489 i->Send(new PluginProcessMsg_SetIPCLoggingEnabled(enabled));
490 ++i;
[email protected]d55aaa132009-09-28 21:08:04491 }
492}
493
494#endif // IPC_MESSAGE_LOG_ENABLED
495
[email protected]6641bf662009-08-21 00:34:09496void BrowserProcessImpl::DoInspectorFilesCheck() {
497 // Runs on FILE thread.
498 DCHECK(file_thread_->message_loop() == MessageLoop::current());
499 bool result = false;
500
501 FilePath inspector_dir;
502 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) {
503 result = file_util::PathExists(inspector_dir);
504 }
505
506 have_inspector_files_ = result;
507}