OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | |
12 #include "base/bind_helpers.h" | |
11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
12 #include "base/file_util.h" | 14 #include "base/file_util.h" |
13 #include "base/path_service.h" | 15 #include "base/path_service.h" |
14 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
15 #include "base/task.h" | |
16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
17 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
18 #include "chrome/browser/automation/automation_provider_list.h" | 19 #include "chrome/browser/automation/automation_provider_list.h" |
19 #include "chrome/browser/background/background_mode_manager.h" | 20 #include "chrome/browser/background/background_mode_manager.h" |
20 #include "chrome/browser/browser_trial.h" | 21 #include "chrome/browser/browser_trial.h" |
21 #include "chrome/browser/chrome_browser_main.h" | 22 #include "chrome/browser/chrome_browser_main.h" |
22 #include "chrome/browser/chrome_plugin_service_filter.h" | 23 #include "chrome/browser/chrome_plugin_service_filter.h" |
23 #include "chrome/browser/component_updater/component_updater_configurator.h" | 24 #include "chrome/browser/component_updater/component_updater_configurator.h" |
24 #include "chrome/browser/component_updater/component_updater_service.h" | 25 #include "chrome/browser/component_updater/component_updater_service.h" |
25 #include "chrome/browser/debugger/devtools_protocol_handler.h" | 26 #include "chrome/browser/debugger/devtools_protocol_handler.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 // before the profiles, since if there are any still showing we will access | 208 // before the profiles, since if there are any still showing we will access |
208 // those things during teardown. | 209 // those things during teardown. |
209 notification_ui_manager_.reset(); | 210 notification_ui_manager_.reset(); |
210 | 211 |
211 // FIXME - We shouldn't need this, it's because of DefaultRequestContext! :( | 212 // FIXME - We shouldn't need this, it's because of DefaultRequestContext! :( |
212 // We need to kill off all URLFetchers using profile related | 213 // We need to kill off all URLFetchers using profile related |
213 // URLRequestContexts. Normally that'd be covered by deleting the Profiles, | 214 // URLRequestContexts. Normally that'd be covered by deleting the Profiles, |
214 // but we have some URLFetchers using the DefaultRequestContext, so they need | 215 // but we have some URLFetchers using the DefaultRequestContext, so they need |
215 // to be cancelled too. Remove this when DefaultRequestContext goes away. | 216 // to be cancelled too. Remove this when DefaultRequestContext goes away. |
216 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 217 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
217 NewRunnableFunction(&content::URLFetcher::CancelAll)); | 218 base::Bind(&content::URLFetcher::CancelAll)); |
218 | 219 |
219 // Need to clear profiles (download managers) before the io_thread_. | 220 // Need to clear profiles (download managers) before the io_thread_. |
220 profile_manager_.reset(); | 221 profile_manager_.reset(); |
221 | 222 |
222 // Debugger must be cleaned up before IO thread and NotificationService. | 223 // Debugger must be cleaned up before IO thread and NotificationService. |
223 remote_debugging_server_.reset(); | 224 remote_debugging_server_.reset(); |
224 | 225 |
225 if (devtools_legacy_handler_.get()) { | 226 if (devtools_legacy_handler_.get()) { |
226 devtools_legacy_handler_->Stop(); | 227 devtools_legacy_handler_->Stop(); |
227 devtools_legacy_handler_ = NULL; | 228 devtools_legacy_handler_ = NULL; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 DCHECK_NE(0u, module_ref_count_); | 318 DCHECK_NE(0u, module_ref_count_); |
318 module_ref_count_--; | 319 module_ref_count_--; |
319 if (0 == module_ref_count_) { | 320 if (0 == module_ref_count_) { |
320 CHECK(MessageLoop::current()->is_running()); | 321 CHECK(MessageLoop::current()->is_running()); |
321 // Allow UI and IO threads to do blocking IO on shutdown, since we do a lot | 322 // Allow UI and IO threads to do blocking IO on shutdown, since we do a lot |
322 // of it on shutdown for valid reasons. | 323 // of it on shutdown for valid reasons. |
323 base::ThreadRestrictions::SetIOAllowed(true); | 324 base::ThreadRestrictions::SetIOAllowed(true); |
324 CHECK(!BrowserList::GetLastActive()); | 325 CHECK(!BrowserList::GetLastActive()); |
325 io_thread()->message_loop()->PostTask( | 326 io_thread()->message_loop()->PostTask( |
326 FROM_HERE, | 327 FROM_HERE, |
327 NewRunnableFunction(&base::ThreadRestrictions::SetIOAllowed, true)); | 328 base::IgnoreReturn<bool>( |
willchan no longer on Chromium
2011/11/19 20:58:24
I'm not sure if the template parameter is necessar
dcheng
2011/11/19 21:15:24
It seems to be necessary in general... except in t
willchan no longer on Chromium
2011/11/19 21:17:55
Can you show me the compilation errors you encount
dcheng
2011/11/19 21:21:27
CXX(target) out/Debug/obj.target/browser/chrome/br
| |
329 base::Bind(&base::ThreadRestrictions::SetIOAllowed, true))); | |
328 | 330 |
329 #if defined(OS_MACOSX) | 331 #if defined(OS_MACOSX) |
330 MessageLoop::current()->PostTask( | 332 MessageLoop::current()->PostTask( |
331 FROM_HERE, | 333 FROM_HERE, |
332 NewRunnableFunction(ChromeBrowserMainPartsMac::DidEndMainMessageLoop)); | 334 base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop)); |
333 #endif | 335 #endif |
334 MessageLoop::current()->Quit(); | 336 MessageLoop::current()->Quit(); |
335 } | 337 } |
336 return module_ref_count_; | 338 return module_ref_count_; |
337 } | 339 } |
338 | 340 |
339 void BrowserProcessImpl::EndSession() { | 341 void BrowserProcessImpl::EndSession() { |
340 // Mark all the profiles as clean. | 342 // Mark all the profiles as clean. |
341 ProfileManager* pm = profile_manager(); | 343 ProfileManager* pm = profile_manager(); |
342 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); | 344 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); |
(...skipping 10 matching lines...) Expand all Loading... | |
353 } | 355 } |
354 | 356 |
355 // We must write that the profile and metrics service shutdown cleanly, | 357 // We must write that the profile and metrics service shutdown cleanly, |
356 // otherwise on startup we'll think we crashed. So we block until done and | 358 // otherwise on startup we'll think we crashed. So we block until done and |
357 // then proceed with normal shutdown. | 359 // then proceed with normal shutdown. |
358 #if defined(USE_X11) | 360 #if defined(USE_X11) |
359 // Can't run a local loop on linux. Instead create a waitable event. | 361 // Can't run a local loop on linux. Instead create a waitable event. |
360 scoped_ptr<base::WaitableEvent> done_writing( | 362 scoped_ptr<base::WaitableEvent> done_writing( |
361 new base::WaitableEvent(false, false)); | 363 new base::WaitableEvent(false, false)); |
362 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 364 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
363 NewRunnableFunction(Signal, done_writing.get())); | 365 base::Bind(Signal, done_writing.get())); |
364 // If all file writes haven't cleared in the timeout, leak the WaitableEvent | 366 // If all file writes haven't cleared in the timeout, leak the WaitableEvent |
365 // so that there's no race to reference it in Signal(). | 367 // so that there's no race to reference it in Signal(). |
366 if (!done_writing->TimedWait( | 368 if (!done_writing->TimedWait( |
367 base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds))) | 369 base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds))) |
368 ignore_result(done_writing.release()); | 370 ignore_result(done_writing.release()); |
369 | 371 |
370 #elif defined(OS_WIN) | 372 #elif defined(OS_WIN) |
371 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 373 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
372 NewRunnableFunction(PostQuit, MessageLoop::current())); | 374 base::Bind(PostQuit, MessageLoop::current())); |
373 int quits_received = 0; | 375 int quits_received = 0; |
374 do { | 376 do { |
375 MessageLoop::current()->Run(); | 377 MessageLoop::current()->Run(); |
376 ++quits_received; | 378 ++quits_received; |
377 } while (!g_end_session_file_thread_has_completed); | 379 } while (!g_end_session_file_thread_has_completed); |
378 // If we did get extra quits, then we should re-post them to the message loop. | 380 // If we did get extra quits, then we should re-post them to the message loop. |
379 while (--quits_received > 0) | 381 while (--quits_received > 0) |
380 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 382 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
381 #else | 383 #else |
382 NOTIMPLEMENTED(); | 384 NOTIMPLEMENTED(); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1098 } | 1100 } |
1099 | 1101 |
1100 void BrowserProcessImpl::OnAutoupdateTimer() { | 1102 void BrowserProcessImpl::OnAutoupdateTimer() { |
1101 if (CanAutorestartForUpdate()) { | 1103 if (CanAutorestartForUpdate()) { |
1102 DLOG(WARNING) << "Detected update. Restarting browser."; | 1104 DLOG(WARNING) << "Detected update. Restarting browser."; |
1103 RestartBackgroundInstance(); | 1105 RestartBackgroundInstance(); |
1104 } | 1106 } |
1105 } | 1107 } |
1106 | 1108 |
1107 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1109 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |