Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Side by Side Diff: chrome/browser/background/background_mode_manager.cc

Issue 796963002: Instrument some of the exit paths likely to suffer hangs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@end_session_instrument
Patch Set: Add instrumentation for browser exit, plus now actually compiles Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "content/public/browser/user_metrics.h" 46 #include "content/public/browser/user_metrics.h"
47 #include "extensions/browser/extension_system.h" 47 #include "extensions/browser/extension_system.h"
48 #include "extensions/common/constants.h" 48 #include "extensions/common/constants.h"
49 #include "extensions/common/extension.h" 49 #include "extensions/common/extension.h"
50 #include "extensions/common/manifest_handlers/options_page_info.h" 50 #include "extensions/common/manifest_handlers/options_page_info.h"
51 #include "extensions/common/permissions/permission_set.h" 51 #include "extensions/common/permissions/permission_set.h"
52 #include "grit/chrome_unscaled_resources.h" 52 #include "grit/chrome_unscaled_resources.h"
53 #include "ui/base/l10n/l10n_util.h" 53 #include "ui/base/l10n/l10n_util.h"
54 #include "ui/base/resource/resource_bundle.h" 54 #include "ui/base/resource/resource_bundle.h"
55 55
56 #if defined(OS_WIN)
57 #include "components/browser_watcher/exit_funnel_win.h"
58 #endif
59
56 using base::UserMetricsAction; 60 using base::UserMetricsAction;
57 using extensions::Extension; 61 using extensions::Extension;
58 using extensions::UpdatedExtensionPermissionsInfo; 62 using extensions::UpdatedExtensionPermissionsInfo;
59 63
60 namespace { 64 namespace {
61 const int kInvalidExtensionIndex = -1; 65 const int kInvalidExtensionIndex = -1;
62 } 66 }
63 67
64 BackgroundModeManager::BackgroundModeData::BackgroundModeData( 68 BackgroundModeManager::BackgroundModeData::BackgroundModeData(
65 Profile* profile, 69 Profile* profile,
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 case IDC_TASK_MANAGER: 529 case IDC_TASK_MANAGER:
526 if (bmd) { 530 if (bmd) {
527 chrome::OpenTaskManager(bmd->GetBrowserWindow()); 531 chrome::OpenTaskManager(bmd->GetBrowserWindow());
528 } else { 532 } else {
529 UserManager::Show(base::FilePath(), 533 UserManager::Show(base::FilePath(),
530 profiles::USER_MANAGER_NO_TUTORIAL, 534 profiles::USER_MANAGER_NO_TUTORIAL,
531 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER); 535 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER);
532 } 536 }
533 break; 537 break;
534 case IDC_EXIT: 538 case IDC_EXIT:
539 #if defined(OS_WIN)
540 browser_watcher::ExitFunnel::RecordSingleEvent(
541 chrome::kBrowserExitCodesRegistryPath, L"TraybarExit");
542 #endif
535 content::RecordAction(UserMetricsAction("Exit")); 543 content::RecordAction(UserMetricsAction("Exit"));
536 chrome::CloseAllBrowsers(); 544 chrome::CloseAllBrowsers();
537 break; 545 break;
538 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: { 546 case IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND: {
539 // Background mode must already be enabled (as otherwise this menu would 547 // Background mode must already be enabled (as otherwise this menu would
540 // not be visible). 548 // not be visible).
541 DCHECK(IsBackgroundModePrefEnabled()); 549 DCHECK(IsBackgroundModePrefEnabled());
542 DCHECK(chrome::WillKeepAlive()); 550 DCHECK(chrome::WillKeepAlive());
543 551
544 // Set the background mode pref to "disabled" - the resulting notification 552 // Set the background mode pref to "disabled" - the resulting notification
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 void BackgroundModeManager::ResumeBackgroundMode() { 639 void BackgroundModeManager::ResumeBackgroundMode() {
632 background_mode_suspended_ = false; 640 background_mode_suspended_ = false;
633 UpdateKeepAliveAndTrayIcon(); 641 UpdateKeepAliveAndTrayIcon();
634 } 642 }
635 643
636 void BackgroundModeManager::UpdateKeepAliveAndTrayIcon() { 644 void BackgroundModeManager::UpdateKeepAliveAndTrayIcon() {
637 if (in_background_mode_ && !background_mode_suspended_) { 645 if (in_background_mode_ && !background_mode_suspended_) {
638 if (!keeping_alive_) { 646 if (!keeping_alive_) {
639 keeping_alive_ = true; 647 keeping_alive_ = true;
640 chrome::IncrementKeepAliveCount(); 648 chrome::IncrementKeepAliveCount();
649
650 #if defined(OS_WIN)
651 browser_watcher::ExitFunnel::RecordSingleEvent(
652 chrome::kBrowserExitCodesRegistryPath, L"BackgroundOn");
653 #endif
641 } 654 }
642 CreateStatusTrayIcon(); 655 CreateStatusTrayIcon();
643 return; 656 return;
644 } 657 }
645 658
646 RemoveStatusTrayIcon(); 659 RemoveStatusTrayIcon();
647 if (keeping_alive_) { 660 if (keeping_alive_) {
648 keeping_alive_ = false; 661 keeping_alive_ = false;
649 chrome::DecrementKeepAliveCount(); 662 chrome::DecrementKeepAliveCount();
663
664 #if defined(OS_WIN)
665 browser_watcher::ExitFunnel::RecordSingleEvent(
666 chrome::kBrowserExitCodesRegistryPath, L"BackgroundOff");
667 #endif
650 } 668 }
651 } 669 }
652 670
653 void BackgroundModeManager::OnBrowserAdded(Browser* browser) { 671 void BackgroundModeManager::OnBrowserAdded(Browser* browser) {
654 ResumeBackgroundMode(); 672 ResumeBackgroundMode();
655 } 673 }
656 674
657 int BackgroundModeManager::GetBackgroundAppCount() const { 675 int BackgroundModeManager::GetBackgroundAppCount() const {
658 int count = 0; 676 int count = 0;
659 // Walk the BackgroundModeData for all profiles and count the number of apps. 677 // Walk the BackgroundModeData for all profiles and count the number of apps.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 } 858 }
841 } 859 }
842 return profile_it; 860 return profile_it;
843 } 861 }
844 862
845 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { 863 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const {
846 PrefService* service = g_browser_process->local_state(); 864 PrefService* service = g_browser_process->local_state();
847 DCHECK(service); 865 DCHECK(service);
848 return service->GetBoolean(prefs::kBackgroundModeEnabled); 866 return service->GetBoolean(prefs::kBackgroundModeEnabled);
849 } 867 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/lifetime/application_lifetime.cc » ('j') | chrome/chrome_watcher/chrome_watcher_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698