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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 468 |
469 // Mark all the profiles as clean. | 469 // Mark all the profiles as clean. |
470 ProfileManager* pm = profile_manager(); | 470 ProfileManager* pm = profile_manager(); |
471 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); | 471 std::vector<Profile*> profiles(pm->GetLoadedProfiles()); |
472 scoped_refptr<RundownTaskCounter> rundown_counter(new RundownTaskCounter()); | 472 scoped_refptr<RundownTaskCounter> rundown_counter(new RundownTaskCounter()); |
473 for (size_t i = 0; i < profiles.size(); ++i) { | 473 for (size_t i = 0; i < profiles.size(); ++i) { |
474 Profile* profile = profiles[i]; | 474 Profile* profile = profiles[i]; |
475 profile->SetExitType(Profile::EXIT_SESSION_ENDED); | 475 profile->SetExitType(Profile::EXIT_SESSION_ENDED); |
476 | 476 |
477 if (!use_broken_synchronization) | 477 if (!use_broken_synchronization) |
478 rundown_counter->Post(profile->GetIOTaskRunner()); | 478 rundown_counter->Post(profile->GetIOTaskRunner().get()); |
479 } | 479 } |
480 | 480 |
481 // Tell the metrics service it was cleanly shutdown. | 481 // Tell the metrics service it was cleanly shutdown. |
482 metrics::MetricsService* metrics = g_browser_process->metrics_service(); | 482 metrics::MetricsService* metrics = g_browser_process->metrics_service(); |
483 if (metrics && local_state()) { | 483 if (metrics && local_state()) { |
484 metrics->RecordStartOfSessionEnd(); | 484 metrics->RecordStartOfSessionEnd(); |
485 #if !defined(OS_CHROMEOS) | 485 #if !defined(OS_CHROMEOS) |
486 // MetricsService lazily writes to prefs, force it to write now. | 486 // MetricsService lazily writes to prefs, force it to write now. |
487 // On ChromeOS, chrome gets killed when hangs, so no need to | 487 // On ChromeOS, chrome gets killed when hangs, so no need to |
488 // commit metrics::prefs::kStabilitySessionEndCompleted change immediately. | 488 // commit metrics::prefs::kStabilitySessionEndCompleted change immediately. |
489 local_state()->CommitPendingWrite(); | 489 local_state()->CommitPendingWrite(); |
490 | 490 |
491 if (!use_broken_synchronization) | 491 if (!use_broken_synchronization) |
492 rundown_counter->Post(local_state_task_runner_.get()); | 492 rundown_counter->Post(local_state_task_runner_.get()); |
493 #endif | 493 #endif |
494 } | 494 } |
495 | 495 |
496 // http://crbug.com/125207 | 496 // http://crbug.com/125207 |
497 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 497 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
498 | 498 |
499 // We must write that the profile and metrics service shutdown cleanly, | 499 // We must write that the profile and metrics service shutdown cleanly, |
500 // otherwise on startup we'll think we crashed. So we block until done and | 500 // otherwise on startup we'll think we crashed. So we block until done and |
501 // then proceed with normal shutdown. | 501 // then proceed with normal shutdown. |
502 // | 502 // |
503 // If you change the condition here, be sure to also change | 503 // If you change the condition here, be sure to also change |
504 // ProfileBrowserTests to match. | 504 // ProfileBrowserTests to match. |
505 #if defined(USE_X11) || defined(OS_WIN) | 505 #if defined(USE_X11) || defined(OS_WIN) |
506 if (use_broken_synchronization) { | 506 if (use_broken_synchronization) { |
507 rundown_counter->Post( | 507 rundown_counter->Post( |
508 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 508 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get()); |
509 } | 509 } |
510 | 510 |
511 // Do a best-effort wait on the successful countdown of rundown tasks. Note | 511 // Do a best-effort wait on the successful countdown of rundown tasks. Note |
512 // that if we don't complete "quickly enough", Windows will terminate our | 512 // that if we don't complete "quickly enough", Windows will terminate our |
513 // process. | 513 // process. |
514 // | 514 // |
515 // On Windows, we previously posted a message to FILE and then ran a nested | 515 // On Windows, we previously posted a message to FILE and then ran a nested |
516 // message loop, waiting for that message to be processed until quitting. | 516 // message loop, waiting for that message to be processed until quitting. |
517 // However, doing so means that other messages will also be processed. In | 517 // However, doing so means that other messages will also be processed. In |
518 // particular, if the GPU process host notices that the GPU has been killed | 518 // particular, if the GPU process host notices that the GPU has been killed |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 } | 1212 } |
1213 | 1213 |
1214 void BrowserProcessImpl::OnAutoupdateTimer() { | 1214 void BrowserProcessImpl::OnAutoupdateTimer() { |
1215 if (CanAutorestartForUpdate()) { | 1215 if (CanAutorestartForUpdate()) { |
1216 DLOG(WARNING) << "Detected update. Restarting browser."; | 1216 DLOG(WARNING) << "Detected update. Restarting browser."; |
1217 RestartBackgroundInstance(); | 1217 RestartBackgroundInstance(); |
1218 } | 1218 } |
1219 } | 1219 } |
1220 | 1220 |
1221 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1221 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |