OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // IOThread object being NULL is considered synonymous with the | 294 // IOThread object being NULL is considered synonymous with the |
295 // IO thread having stopped. | 295 // IO thread having stopped. |
296 io_thread_.reset(); | 296 io_thread_.reset(); |
297 } | 297 } |
298 | 298 |
299 #if defined(OS_WIN) | 299 #if defined(OS_WIN) |
300 // Send a QuitTask to the given MessageLoop when the (file) thread has processed | 300 // Send a QuitTask to the given MessageLoop when the (file) thread has processed |
301 // our (other) recent requests (to save preferences). | 301 // our (other) recent requests (to save preferences). |
302 // Change the boolean so that the receiving thread will know that we did indeed | 302 // Change the boolean so that the receiving thread will know that we did indeed |
303 // send the QuitTask that terminated the message loop. | 303 // send the QuitTask that terminated the message loop. |
304 static void PostQuit(MessageLoop* message_loop) { | 304 static void PostQuit(base::MessageLoop* message_loop) { |
305 g_end_session_file_thread_has_completed = true; | 305 g_end_session_file_thread_has_completed = true; |
306 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 306 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
307 } | 307 } |
308 #elif defined(USE_X11) | 308 #elif defined(USE_X11) |
309 static void Signal(base::WaitableEvent* event) { | 309 static void Signal(base::WaitableEvent* event) { |
310 event->Signal(); | 310 event->Signal(); |
311 } | 311 } |
312 #endif | 312 #endif |
313 | 313 |
314 unsigned int BrowserProcessImpl::AddRefModule() { | 314 unsigned int BrowserProcessImpl::AddRefModule() { |
315 DCHECK(CalledOnValidThread()); | 315 DCHECK(CalledOnValidThread()); |
316 | 316 |
(...skipping 19 matching lines...) Expand all Loading... |
336 release_last_reference_callstack_ = base::debug::StackTrace(); | 336 release_last_reference_callstack_ = base::debug::StackTrace(); |
337 | 337 |
338 #if defined(ENABLE_PRINTING) | 338 #if defined(ENABLE_PRINTING) |
339 // Wait for the pending print jobs to finish. Don't do this later, since | 339 // Wait for the pending print jobs to finish. Don't do this later, since |
340 // this might cause a nested message loop to run, and we don't want pending | 340 // this might cause a nested message loop to run, and we don't want pending |
341 // tasks to run once teardown has started. | 341 // tasks to run once teardown has started. |
342 print_job_manager_->OnQuit(); | 342 print_job_manager_->OnQuit(); |
343 print_job_manager_.reset(); | 343 print_job_manager_.reset(); |
344 #endif | 344 #endif |
345 | 345 |
346 CHECK(MessageLoop::current()->is_running()); | 346 CHECK(base::MessageLoop::current()->is_running()); |
347 | 347 |
348 #if defined(OS_MACOSX) | 348 #if defined(OS_MACOSX) |
349 MessageLoop::current()->PostTask( | 349 base::MessageLoop::current()->PostTask( |
350 FROM_HERE, | 350 FROM_HERE, |
351 base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop)); | 351 base::Bind(ChromeBrowserMainPartsMac::DidEndMainMessageLoop)); |
352 #endif | 352 #endif |
353 MessageLoop::current()->Quit(); | 353 base::MessageLoop::current()->Quit(); |
354 } | 354 } |
355 return module_ref_count_; | 355 return module_ref_count_; |
356 } | 356 } |
357 | 357 |
358 void BrowserProcessImpl::EndSession() { | 358 void BrowserProcessImpl::EndSession() { |
359 // Mark all the profiles as clean. | 359 // Mark all the profiles as clean. |
360 ProfileManager* pm = profile_manager(); | 360 ProfileManager* pm = profile_manager(); |
361 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); | 361 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); |
362 for (size_t i = 0; i < profiles.size(); ++i) | 362 for (size_t i = 0; i < profiles.size(); ++i) |
363 profiles[i]->SetExitType(Profile::EXIT_SESSION_ENDED); | 363 profiles[i]->SetExitType(Profile::EXIT_SESSION_ENDED); |
(...skipping 20 matching lines...) Expand all Loading... |
384 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 384 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
385 base::Bind(Signal, done_writing.get())); | 385 base::Bind(Signal, done_writing.get())); |
386 // If all file writes haven't cleared in the timeout, leak the WaitableEvent | 386 // If all file writes haven't cleared in the timeout, leak the WaitableEvent |
387 // so that there's no race to reference it in Signal(). | 387 // so that there's no race to reference it in Signal(). |
388 if (!done_writing->TimedWait( | 388 if (!done_writing->TimedWait( |
389 base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds))) { | 389 base::TimeDelta::FromSeconds(kEndSessionTimeoutSeconds))) { |
390 ignore_result(done_writing.release()); | 390 ignore_result(done_writing.release()); |
391 } | 391 } |
392 | 392 |
393 #elif defined(OS_WIN) | 393 #elif defined(OS_WIN) |
394 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 394 BrowserThread::PostTask(BrowserThread::FILE, |
395 base::Bind(PostQuit, MessageLoop::current())); | 395 FROM_HERE, |
| 396 base::Bind(PostQuit, base::MessageLoop::current())); |
396 int quits_received = 0; | 397 int quits_received = 0; |
397 do { | 398 do { |
398 MessageLoop::current()->Run(); | 399 base::MessageLoop::current()->Run(); |
399 ++quits_received; | 400 ++quits_received; |
400 } while (!g_end_session_file_thread_has_completed); | 401 } while (!g_end_session_file_thread_has_completed); |
401 // If we did get extra quits, then we should re-post them to the message loop. | 402 // If we did get extra quits, then we should re-post them to the message loop. |
402 while (--quits_received > 0) | 403 while (--quits_received > 0) |
403 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 404 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 405 base::MessageLoop::QuitClosure()); |
404 #else | 406 #else |
405 NOTIMPLEMENTED(); | 407 NOTIMPLEMENTED(); |
406 #endif | 408 #endif |
407 } | 409 } |
408 | 410 |
409 MetricsService* BrowserProcessImpl::metrics_service() { | 411 MetricsService* BrowserProcessImpl::metrics_service() { |
410 DCHECK(CalledOnValidThread()); | 412 DCHECK(CalledOnValidThread()); |
411 if (!created_metrics_service_) | 413 if (!created_metrics_service_) |
412 CreateMetricsService(); | 414 CreateMetricsService(); |
413 return metrics_service_.get(); | 415 return metrics_service_.get(); |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 } | 1063 } |
1062 | 1064 |
1063 void BrowserProcessImpl::OnAutoupdateTimer() { | 1065 void BrowserProcessImpl::OnAutoupdateTimer() { |
1064 if (CanAutorestartForUpdate()) { | 1066 if (CanAutorestartForUpdate()) { |
1065 DLOG(WARNING) << "Detected update. Restarting browser."; | 1067 DLOG(WARNING) << "Detected update. Restarting browser."; |
1066 RestartBackgroundInstance(); | 1068 RestartBackgroundInstance(); |
1067 } | 1069 } |
1068 } | 1070 } |
1069 | 1071 |
1070 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1072 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |