blob: fdc414834b30132a3272a824e54f65d399509969 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2// 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]a92b8642009-05-05 23:38:567#include "app/l10n_util.h"
[email protected]1b8d02f12009-05-05 04:14:118#include "base/clipboard.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]fd49e2d2009-02-20 17:21:3025#include "chrome/browser/plugin_service.h"
initial.commit09911bf2008-07-26 23:55:2926#include "chrome/browser/profile_manager.h"
[email protected]8c8657d62009-01-16 18:31:2627#include "chrome/browser/renderer_host/render_process_host.h"
[email protected]81218f42009-02-05 18:48:0828#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
29#include "chrome/browser/safe_browsing/safe_browsing_service.h"
initial.commit09911bf2008-07-26 23:55:2930#include "chrome/common/chrome_paths.h"
31#include "chrome/common/chrome_switches.h"
initial.commit09911bf2008-07-26 23:55:2932#include "chrome/common/notification_service.h"
33#include "chrome/common/pref_names.h"
34#include "chrome/common/pref_service.h"
[email protected]d55aaa132009-09-28 21:08:0435#include "ipc/ipc_logging.h"
[email protected]b112a4c2009-02-01 20:24:0136
37#if defined(OS_WIN)
38#include "chrome/browser/automation/automation_provider_list.h"
[email protected]b112a4c2009-02-01 20:24:0139#include "chrome/browser/printing/print_job_manager.h"
[email protected]2362e4f2009-05-08 00:34:0540#include "views/focus/view_storage.h"
[email protected]81218f42009-02-05 18:48:0841#elif defined(OS_POSIX)
42// TODO(port): Remove the temporary scaffolding as we port the above headers.
43#include "chrome/common/temp_scaffolding_stubs.h"
[email protected]b112a4c2009-02-01 20:24:0144#endif
initial.commit09911bf2008-07-26 23:55:2945
[email protected]d55aaa132009-09-28 21:08:0446#if defined(IPC_MESSAGE_LOG_ENABLED)
47#include "chrome/common/plugin_messages.h"
48#include "chrome/common/render_messages.h"
49#endif
50
initial.commit09911bf2008-07-26 23:55:2951namespace {
52
53// ----------------------------------------------------------------------------
54// BrowserProcessSubThread
55//
56// This simple thread object is used for the specialized threads that the
57// BrowserProcess spins up.
58//
59// Applications must initialize the COM library before they can call
60// COM library functions other than CoGetMalloc and memory allocation
61// functions, so this class initializes COM for those users.
62class BrowserProcessSubThread : public ChromeThread {
63 public:
64 explicit BrowserProcessSubThread(ChromeThread::ID identifier)
65 : ChromeThread(identifier) {
66 }
67
[email protected]48ca9012009-08-11 21:38:5468 virtual ~BrowserProcessSubThread() {
initial.commit09911bf2008-07-26 23:55:2969 // We cannot rely on our base class to stop the thread since we want our
70 // CleanUp function to run.
71 Stop();
72 }
73
74 protected:
75 virtual void Init() {
[email protected]b112a4c2009-02-01 20:24:0176#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:2977 // Initializes the COM library on the current thread.
78 CoInitialize(NULL);
[email protected]b112a4c2009-02-01 20:24:0179#endif
initial.commit09911bf2008-07-26 23:55:2980
81 notification_service_ = new NotificationService;
82 }
83
84 virtual void CleanUp() {
85 delete notification_service_;
86 notification_service_ = NULL;
87
[email protected]b112a4c2009-02-01 20:24:0188#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:2989 // Closes the COM library on the current thread. CoInitialize must
90 // be balanced by a corresponding call to CoUninitialize.
91 CoUninitialize();
[email protected]b112a4c2009-02-01 20:24:0192#endif
initial.commit09911bf2008-07-26 23:55:2993 }
94
95 private:
96 // Each specialized thread has its own notification service.
97 // Note: We don't use scoped_ptr because the destructor runs on the wrong
98 // thread.
99 NotificationService* notification_service_;
100};
101
[email protected]48ca9012009-08-11 21:38:54102class IOThread : public BrowserProcessSubThread {
103 public:
104 IOThread() : BrowserProcessSubThread(ChromeThread::IO) {}
105
106 virtual ~IOThread() {
107 // We cannot rely on our base class to stop the thread since we want our
108 // CleanUp function to run.
109 Stop();
110 }
111
112 protected:
113 virtual void CleanUp() {
114 // URLFetcher and URLRequest instances must NOT outlive the IO thread.
[email protected]03a69dc2009-09-22 00:04:59115 //
116 // Strictly speaking, URLFetcher's CheckForLeaks() should be done on the
117 // UI thread. However, since there _shouldn't_ be any instances left
118 // at this point, it shouldn't be a race.
119 //
120 // We check URLFetcher first, since if it has leaked then an associated
121 // URLRequest will also have leaked. However it is more useful to
122 // crash showing the callstack of URLFetcher's allocation than its
123 // URLRequest member.
[email protected]48ca9012009-08-11 21:38:54124 base::LeakTracker<URLFetcher>::CheckForLeaks();
[email protected]03a69dc2009-09-22 00:04:59125 base::LeakTracker<URLRequest>::CheckForLeaks();
[email protected]48ca9012009-08-11 21:38:54126
127 BrowserProcessSubThread::CleanUp();
128 }
129};
130
initial.commit09911bf2008-07-26 23:55:29131} // namespace
132
[email protected]bb975362009-01-21 01:00:22133BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
initial.commit09911bf2008-07-26 23:55:29134 : created_resource_dispatcher_host_(false),
135 created_metrics_service_(false),
136 created_io_thread_(false),
137 created_file_thread_(false),
138 created_db_thread_(false),
139 created_profile_manager_(false),
140 created_local_state_(false),
[email protected]f3a4f302009-08-21 22:35:29141#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29142 initialized_broker_services_(false),
initial.commit09911bf2008-07-26 23:55:29143 broker_services_(NULL),
[email protected]f3a4f302009-08-21 22:35:29144#endif // defined(OS_WIN)
[email protected]b112a4c2009-02-01 20:24:01145 created_icon_manager_(false),
146 created_debugger_wrapper_(false),
[email protected]40ecc902009-03-16 13:42:47147 created_devtools_manager_(false),
initial.commit09911bf2008-07-26 23:55:29148 module_ref_count_(0),
[email protected]ecfa8b392009-08-20 15:44:33149 memory_model_(HIGH_MEMORY_MODEL),
[email protected]1b2db1a2008-08-08 17:46:13150 checked_for_new_frames_(false),
[email protected]6641bf662009-08-21 00:34:09151 using_new_frames_(false),
152 have_inspector_files_(true) {
initial.commit09911bf2008-07-26 23:55:29153 g_browser_process = this;
[email protected]1b8d02f12009-05-05 04:14:11154 clipboard_.reset(new Clipboard);
initial.commit09911bf2008-07-26 23:55:29155 main_notification_service_.reset(new NotificationService);
156
157 // Must be created after the NotificationService.
158 print_job_manager_.reset(new printing::PrintJobManager);
159
160 // Configure the browser memory model.
161 if (command_line.HasSwitch(switches::kMemoryModel)) {
162 std::wstring model = command_line.GetSwitchValue(switches::kMemoryModel);
163 if (!model.empty()) {
164 if (model == L"high")
165 memory_model_ = HIGH_MEMORY_MODEL;
166 else if (model == L"low")
167 memory_model_ = LOW_MEMORY_MODEL;
168 else if (model == L"medium")
169 memory_model_ = MEDIUM_MEMORY_MODEL;
170 }
171 }
[email protected]b797e152009-01-23 16:06:14172 shutdown_event_.reset(new base::WaitableEvent(true, false));
initial.commit09911bf2008-07-26 23:55:29173}
174
175BrowserProcessImpl::~BrowserProcessImpl() {
176 // Delete the AutomationProviderList before NotificationService,
177 // since it may try to unregister notifications
178 // Both NotificationService and AutomationProvider are singleton instances in
179 // the BrowserProcess. Since AutomationProvider may have some active
180 // notification observers, it is essential that it gets destroyed before the
181 // NotificationService. NotificationService won't be destroyed until after
182 // this destructor is run.
183 automation_provider_list_.reset();
184
[email protected]d393a0fd2009-05-13 23:32:01185 // We need to shutdown the SdchDictionaryFetcher as it regularly holds
186 // a pointer to a URLFetcher, and that URLFetcher (upon destruction) will do
187 // a PostDelayedTask onto the IO thread. This shutdown call will both discard
188 // any pending URLFetchers, and avoid creating any more.
189 SdchDictionaryFetcher::Shutdown();
190
initial.commit09911bf2008-07-26 23:55:29191 // We need to destroy the MetricsService and GoogleURLTracker before the
192 // io_thread_ gets destroyed, since both destructors can call the URLFetcher
[email protected]d393a0fd2009-05-13 23:32:01193 // destructor, which does an PostDelayedTask operation on the IO thread. (The
194 // IO thread will handle that URLFetcher operation before going away.)
initial.commit09911bf2008-07-26 23:55:29195 metrics_service_.reset();
196 google_url_tracker_.reset();
197
198 // Need to clear profiles (download managers) before the io_thread_.
199 profile_manager_.reset();
200
201 // Debugger must be cleaned up before IO thread and NotificationService.
202 debugger_wrapper_ = NULL;
203
204 if (resource_dispatcher_host_.get()) {
205 // Need to tell Safe Browsing Service that the IO thread is going away
206 // since it cached a pointer to it.
207 if (resource_dispatcher_host()->safe_browsing_service())
208 resource_dispatcher_host()->safe_browsing_service()->ShutDown();
209
210 // Cancel pending requests and prevent new requests.
211 resource_dispatcher_host()->Shutdown();
212 }
213
[email protected]4c3cd7412009-04-22 17:56:06214#if defined(OS_LINUX)
215 // The IO thread must outlive the BACKGROUND_X11 thread.
216 background_x11_thread_.reset();
217#endif
218
initial.commit09911bf2008-07-26 23:55:29219 // Need to stop io_thread_ before resource_dispatcher_host_, since
220 // io_thread_ may still deref ResourceDispatcherHost and handle resource
221 // request before going away.
[email protected]48ca9012009-08-11 21:38:54222 ResetIOThread();
initial.commit09911bf2008-07-26 23:55:29223
224 // Clean up state that lives on the file_thread_ before it goes away.
225 if (resource_dispatcher_host_.get()) {
226 resource_dispatcher_host()->download_file_manager()->Shutdown();
227 resource_dispatcher_host()->save_file_manager()->Shutdown();
228 }
229
230 // Need to stop the file_thread_ here to force it to process messages in its
231 // message loop from the previous call to shutdown the DownloadFileManager,
232 // SaveFileManager and SessionService.
233 file_thread_.reset();
234
235 // With the file_thread_ flushed, we can release any icon resources.
236 icon_manager_.reset();
237
238 // Need to destroy ResourceDispatcherHost before PluginService and
239 // SafeBrowsingService, since it caches a pointer to it.
240 resource_dispatcher_host_.reset();
241
242 // Wait for the pending print jobs to finish.
243 print_job_manager_->OnQuit();
244 print_job_manager_.reset();
245
initial.commit09911bf2008-07-26 23:55:29246 // Now OK to destroy NotificationService.
247 main_notification_service_.reset();
248
249 g_browser_process = NULL;
250}
251
[email protected]295039bd2008-08-15 04:32:57252// Send a QuitTask to the given MessageLoop.
253static void PostQuit(MessageLoop* message_loop) {
254 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
255}
initial.commit09911bf2008-07-26 23:55:29256
257void BrowserProcessImpl::EndSession() {
[email protected]b112a4c2009-02-01 20:24:01258#if defined(OS_WIN)
[email protected]d65cab7a2008-08-12 01:25:41259 // Notify we are going away.
[email protected]b797e152009-01-23 16:06:14260 ::SetEvent(shutdown_event_->handle());
[email protected]b112a4c2009-02-01 20:24:01261#endif
[email protected]d65cab7a2008-08-12 01:25:41262
initial.commit09911bf2008-07-26 23:55:29263 // Mark all the profiles as clean.
264 ProfileManager* pm = profile_manager();
265 for (ProfileManager::const_iterator i = pm->begin(); i != pm->end(); ++i)
266 (*i)->MarkAsCleanShutdown();
267
268 // Tell the metrics service it was cleanly shutdown.
269 MetricsService* metrics = g_browser_process->metrics_service();
270 if (metrics && local_state()) {
271 metrics->RecordCleanShutdown();
272
273 metrics->RecordStartOfSessionEnd();
274
275 // MetricsService lazily writes to prefs, force it to write now.
[email protected]6faa0e0d2009-04-28 06:50:36276 local_state()->SavePersistentPrefs();
initial.commit09911bf2008-07-26 23:55:29277 }
278
279 // We must write that the profile and metrics service shutdown cleanly,
280 // otherwise on startup we'll think we crashed. So we block until done and
281 // then proceed with normal shutdown.
282 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE,
[email protected]295039bd2008-08-15 04:32:57283 NewRunnableFunction(PostQuit, MessageLoop::current()));
initial.commit09911bf2008-07-26 23:55:29284 MessageLoop::current()->Run();
285}
286
287printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
288 // TODO(abarth): DCHECK(CalledOnValidThread());
289 // See <http://b/1287209>.
290 // print_job_manager_ is initialized in the constructor and destroyed in the
291 // destructor, so it should always be valid.
292 DCHECK(print_job_manager_.get());
293 return print_job_manager_.get();
294}
295
[email protected]d70539de2009-06-24 22:17:06296const std::string& BrowserProcessImpl::GetApplicationLocale() {
initial.commit09911bf2008-07-26 23:55:29297 DCHECK(CalledOnValidThread());
298 if (locale_.empty()) {
[email protected]d70539de2009-06-24 22:17:06299 locale_ = l10n_util::GetApplicationLocale(
300 local_state()->GetString(prefs::kApplicationLocale));
initial.commit09911bf2008-07-26 23:55:29301 }
302 return locale_;
303}
304
305void BrowserProcessImpl::CreateResourceDispatcherHost() {
306 DCHECK(!created_resource_dispatcher_host_ &&
307 resource_dispatcher_host_.get() == NULL);
308 created_resource_dispatcher_host_ = true;
309
310 resource_dispatcher_host_.reset(
311 new ResourceDispatcherHost(io_thread()->message_loop()));
312 resource_dispatcher_host_->Initialize();
313}
314
315void BrowserProcessImpl::CreateMetricsService() {
316 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL);
317 created_metrics_service_ = true;
318
319 metrics_service_.reset(new MetricsService);
320}
321
322void BrowserProcessImpl::CreateIOThread() {
323 DCHECK(!created_io_thread_ && io_thread_.get() == NULL);
324 created_io_thread_ = true;
325
326 // Prior to starting the io thread, we create the plugin service as
327 // it is predominantly used from the io thread, but must be created
328 // on the main thread. The service ctor is inexpensive and does not
329 // invoke the io_thread() accessor.
330 PluginService::GetInstance();
331
[email protected]4c3cd7412009-04-22 17:56:06332#if defined(OS_LINUX)
333 // The lifetime of the BACKGROUND_X11 thread is a subset of the IO thread so
334 // we start it now.
335 scoped_ptr<base::Thread> background_x11_thread(
336 new BrowserProcessSubThread(ChromeThread::BACKGROUND_X11));
337 if (!background_x11_thread->Start())
338 return;
339 background_x11_thread_.swap(background_x11_thread);
340#endif
341
[email protected]48ca9012009-08-11 21:38:54342 scoped_ptr<base::Thread> thread(new IOThread);
[email protected]ab820df2008-08-26 05:55:10343 base::Thread::Options options;
344 options.message_loop_type = MessageLoop::TYPE_IO;
345 if (!thread->StartWithOptions(options))
initial.commit09911bf2008-07-26 23:55:29346 return;
347 io_thread_.swap(thread);
348}
349
[email protected]48ca9012009-08-11 21:38:54350void BrowserProcessImpl::ResetIOThread() {
351 if (io_thread_.get()) {
352 io_thread_->message_loop()->PostTask(FROM_HERE,
353 NewRunnableFunction(CleanupOnIOThread));
354 }
355 io_thread_.reset();
356}
357
358// static
359void BrowserProcessImpl::CleanupOnIOThread() {
360 // Shutdown DNS prefetching now to ensure that network stack objects
361 // living on the IO thread get destroyed before the IO thread goes away.
362 chrome_browser_net::EnsureDnsPrefetchShutdown();
363 // TODO(eroman): can this be merged into IOThread::CleanUp() ?
364}
365
initial.commit09911bf2008-07-26 23:55:29366void BrowserProcessImpl::CreateFileThread() {
367 DCHECK(!created_file_thread_ && file_thread_.get() == NULL);
368 created_file_thread_ = true;
369
[email protected]ab820df2008-08-26 05:55:10370 scoped_ptr<base::Thread> thread(
371 new BrowserProcessSubThread(ChromeThread::FILE));
[email protected]a1db3842008-09-17 22:04:06372 base::Thread::Options options;
[email protected]9e549b582009-02-05 21:13:39373#if defined(OS_WIN)
374 // On Windows, the FILE thread needs to be have a UI message loop which pumps
375 // messages in such a way that Google Update can communicate back to us.
[email protected]a1db3842008-09-17 22:04:06376 options.message_loop_type = MessageLoop::TYPE_UI;
[email protected]9e549b582009-02-05 21:13:39377#else
378 options.message_loop_type = MessageLoop::TYPE_IO;
379#endif
[email protected]a1db3842008-09-17 22:04:06380 if (!thread->StartWithOptions(options))
initial.commit09911bf2008-07-26 23:55:29381 return;
382 file_thread_.swap(thread);
383}
384
385void BrowserProcessImpl::CreateDBThread() {
386 DCHECK(!created_db_thread_ && db_thread_.get() == NULL);
387 created_db_thread_ = true;
388
[email protected]ab820df2008-08-26 05:55:10389 scoped_ptr<base::Thread> thread(
390 new BrowserProcessSubThread(ChromeThread::DB));
initial.commit09911bf2008-07-26 23:55:29391 if (!thread->Start())
392 return;
393 db_thread_.swap(thread);
394}
395
396void BrowserProcessImpl::CreateProfileManager() {
397 DCHECK(!created_profile_manager_ && profile_manager_.get() == NULL);
398 created_profile_manager_ = true;
399
400 profile_manager_.reset(new ProfileManager());
401}
402
403void BrowserProcessImpl::CreateLocalState() {
404 DCHECK(!created_local_state_ && local_state_.get() == NULL);
405 created_local_state_ = true;
406
[email protected]b9636002009-03-04 00:05:25407 FilePath local_state_path;
initial.commit09911bf2008-07-26 23:55:29408 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
[email protected]6faa0e0d2009-04-28 06:50:36409 local_state_.reset(new PrefService(local_state_path, file_thread()));
initial.commit09911bf2008-07-26 23:55:29410}
411
[email protected]f3a4f302009-08-21 22:35:29412#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29413void BrowserProcessImpl::InitBrokerServices(
414 sandbox::BrokerServices* broker_services) {
415 DCHECK(!initialized_broker_services_ && broker_services_ == NULL);
416 broker_services->Init();
417 initialized_broker_services_ = true;
418 broker_services_ = broker_services;
419}
[email protected]f3a4f302009-08-21 22:35:29420#endif // defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29421
422void BrowserProcessImpl::CreateIconManager() {
423 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL);
424 created_icon_manager_ = true;
425 icon_manager_.reset(new IconManager);
426}
427
428void BrowserProcessImpl::CreateDebuggerWrapper(int port) {
429 DCHECK(debugger_wrapper_.get() == NULL);
430 created_debugger_wrapper_ = true;
431
432 debugger_wrapper_ = new DebuggerWrapper(port);
433}
434
[email protected]40ecc902009-03-16 13:42:47435void BrowserProcessImpl::CreateDevToolsManager() {
[email protected]73ee01522009-06-05 10:13:44436 DCHECK(devtools_manager_.get() == NULL);
[email protected]40ecc902009-03-16 13:42:47437 created_devtools_manager_ = true;
[email protected]73ee01522009-06-05 10:13:44438 devtools_manager_ = new DevToolsManager();
[email protected]40ecc902009-03-16 13:42:47439}
440
initial.commit09911bf2008-07-26 23:55:29441void BrowserProcessImpl::CreateGoogleURLTracker() {
442 DCHECK(google_url_tracker_.get() == NULL);
443 scoped_ptr<GoogleURLTracker> google_url_tracker(new GoogleURLTracker);
444 google_url_tracker_.swap(google_url_tracker);
445}
[email protected]6641bf662009-08-21 00:34:09446
447// The BrowserProcess object must outlive the file thread so we use traits
448// which don't do any management.
449template <>
450struct RunnableMethodTraits<BrowserProcessImpl> {
[email protected]359e88bc2009-09-28 19:21:41451 static void RetainCallee(BrowserProcessImpl*) {}
452 static void ReleaseCallee(BrowserProcessImpl*) {}
[email protected]6641bf662009-08-21 00:34:09453};
454
455void BrowserProcessImpl::CheckForInspectorFiles() {
456 file_thread()->message_loop()->PostTask
457 (FROM_HERE,
458 NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck));
459}
460
[email protected]d55aaa132009-09-28 21:08:04461#if defined(IPC_MESSAGE_LOG_ENABLED)
462
463void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) {
464 // First enable myself.
465 if (enable)
466 IPC::Logging::current()->Enable();
467 else
468 IPC::Logging::current()->Disable();
469
470 // Now tell subprocesses. Messages to ChildProcess-derived
471 // processes must be done on the IO thread.
472 io_thread()->message_loop()->PostTask
473 (FROM_HERE,
474 NewRunnableMethod(
475 this,
476 &BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses,
477 enable));
478
479 // Finally, tell the renderers which don't derive from ChildProcess.
480 // Messages to the renderers must be done on the UI (main) thread.
481 RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
482 for (RenderProcessHost* host = i.GetCurrentValue();
483 !i.IsAtEnd();
484 i.Advance()) {
485 host->Send(new ViewMsg_SetIPCLoggingEnabled(enable));
486 }
487}
488
489// Helper for SetIPCLoggingEnabled.
490void BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses(bool enabled) {
491 DCHECK(MessageLoop::current() ==
492 ChromeThread::GetMessageLoop(ChromeThread::IO));
493
494 ChildProcessHost::Iterator i; // default constr references a singleton
[email protected]34cf97d2009-09-29 22:46:11495 while (!i.Done()) {
496 i->Send(new PluginProcessMsg_SetIPCLoggingEnabled(enabled));
497 ++i;
[email protected]d55aaa132009-09-28 21:08:04498 }
499}
500
501#endif // IPC_MESSAGE_LOG_ENABLED
502
[email protected]6641bf662009-08-21 00:34:09503void BrowserProcessImpl::DoInspectorFilesCheck() {
504 // Runs on FILE thread.
505 DCHECK(file_thread_->message_loop() == MessageLoop::current());
506 bool result = false;
507
508 FilePath inspector_dir;
509 if (PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir)) {
510 result = file_util::PathExists(inspector_dir);
511 }
512
513 have_inspector_files_ = result;
514}