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/background/background_mode_manager.h" | 5 #include "chrome/browser/background/background_mode_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 std::vector<base::string16> new_client_names; | 456 std::vector<base::string16> new_client_names; |
457 OnClientsChanged(profile, new_client_names); | 457 OnClientsChanged(profile, new_client_names); |
458 } | 458 } |
459 | 459 |
460 /////////////////////////////////////////////////////////////////////////////// | 460 /////////////////////////////////////////////////////////////////////////////// |
461 // BackgroundModeManager, content::NotificationObserver overrides | 461 // BackgroundModeManager, content::NotificationObserver overrides |
462 void BackgroundModeManager::Observe( | 462 void BackgroundModeManager::Observe( |
463 int type, | 463 int type, |
464 const content::NotificationSource& source, | 464 const content::NotificationSource& source, |
465 const content::NotificationDetails& details) { | 465 const content::NotificationDetails& details) { |
466 switch (type) { | 466 DCHECK_EQ(chrome::NOTIFICATION_APP_TERMINATING, type); |
467 case chrome::NOTIFICATION_APP_TERMINATING: | 467 |
468 // Make sure we aren't still keeping the app alive (only happens if we | 468 // Make sure we aren't still keeping the app alive (only happens if we |
469 // don't receive an EXTENSIONS_READY notification for some reason). | 469 // don't receive an EXTENSIONS_READY notification for some reason). |
470 ReleaseStartupKeepAlive(); | 470 ReleaseStartupKeepAlive(); |
471 // Performing an explicit shutdown, so exit background mode (does nothing | 471 // Performing an explicit shutdown, so exit background mode (does nothing |
472 // if we aren't in background mode currently). | 472 // if we aren't in background mode currently). |
473 EndBackgroundMode(); | 473 EndBackgroundMode(); |
474 // Shutting down, so don't listen for any more notifications so we don't | 474 // Shutting down, so don't listen for any more notifications so we don't |
475 // try to re-enter/exit background mode again. | 475 // try to re-enter/exit background mode again. |
476 registrar_.RemoveAll(); | 476 registrar_.RemoveAll(); |
477 for (const auto& it : background_mode_data_) | 477 for (const auto& it : background_mode_data_) |
478 it.second->applications_->RemoveObserver(this); | 478 it.second->applications_->RemoveObserver(this); |
479 break; | |
480 default: | |
481 NOTREACHED(); | |
482 break; | |
483 } | |
484 } | 479 } |
485 | 480 |
486 void BackgroundModeManager::OnExtensionsReady(Profile* profile) { | 481 void BackgroundModeManager::OnExtensionsReady(Profile* profile) { |
487 BackgroundModeManager::BackgroundModeData* bmd = | 482 BackgroundModeManager::BackgroundModeData* bmd = |
488 GetBackgroundModeData(profile); | 483 GetBackgroundModeData(profile); |
489 if (bmd) { | 484 if (bmd) { |
490 UMA_HISTOGRAM_COUNTS_100("BackgroundMode.BackgroundApplicationsCount", | 485 UMA_HISTOGRAM_COUNTS_100("BackgroundMode.BackgroundApplicationsCount", |
491 bmd->applications_->size()); | 486 bmd->applications_->size()); |
492 } | 487 } |
493 // Extensions are loaded, so we don't need to manually keep the browser | 488 // Extensions are loaded, so we don't need to manually keep the browser |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 } | 1024 } |
1030 } | 1025 } |
1031 return profile_it; | 1026 return profile_it; |
1032 } | 1027 } |
1033 | 1028 |
1034 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 1029 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
1035 PrefService* service = g_browser_process->local_state(); | 1030 PrefService* service = g_browser_process->local_state(); |
1036 DCHECK(service); | 1031 DCHECK(service); |
1037 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 1032 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
1038 } | 1033 } |
OLD | NEW |