summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 03:06:37 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 03:06:37 +0000
commit703da7149c1c5d5aac592ed76a48fa676df39dad (patch)
treea1ec931a3fcba78312702fc0002f5781606bde69
parentded63f2998e10150dc3eb8c5b3cdf0ddbe8e1901 (diff)
downloadchromium_src-703da7149c1c5d5aac592ed76a48fa676df39dad.zip
chromium_src-703da7149c1c5d5aac592ed76a48fa676df39dad.tar.gz
chromium_src-703da7149c1c5d5aac592ed76a48fa676df39dad.tar.bz2
Remove unused AppKeepAliveService
For app_shell (go/appshell) we need to remove the circular dependencies from src/apps back to src/chrome. AppKeepAliveService has dependencies on Chrome but is unused, so let's delete it instead of fixing it. BUG=326040 TEST=compiles TBR=erg@chromium.org for deleting an unused include from chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc Review URL: https://codereview.chromium.org/172313004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253695 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--apps/app_keep_alive_service.cc69
-rw-r--r--apps/app_keep_alive_service.h39
-rw-r--r--apps/app_keep_alive_service_factory.cc48
-rw-r--r--apps/app_keep_alive_service_factory.h36
-rw-r--r--apps/app_keep_alive_service_unittest.cc129
-rw-r--r--apps/apps.gypi4
-rw-r--r--chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc1
-rw-r--r--chrome/chrome_tests_unit.gypi1
8 files changed, 0 insertions, 327 deletions
diff --git a/apps/app_keep_alive_service.cc b/apps/app_keep_alive_service.cc
deleted file mode 100644
index 6c9bf7be..0000000
--- a/apps/app_keep_alive_service.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "apps/app_keep_alive_service.h"
-
-#include "apps/app_lifetime_monitor.h"
-#include "apps/app_lifetime_monitor_factory.h"
-#include "base/message_loop/message_loop.h"
-#include "chrome/browser/lifetime/application_lifetime.h"
-#include "chrome/browser/profiles/profile.h"
-
-namespace apps {
-
-AppKeepAliveService::AppKeepAliveService(content::BrowserContext* context)
- : context_(context), shut_down_(false) {
- AppLifetimeMonitor* app_lifetime_monitor =
- AppLifetimeMonitorFactory::GetForProfile(static_cast<Profile*>(context));
- app_lifetime_monitor->AddObserver(this);
-}
-
-AppKeepAliveService::~AppKeepAliveService() {}
-
-void AppKeepAliveService::Shutdown() {
- AppLifetimeMonitor* app_lifetime_monitor =
- AppLifetimeMonitorFactory::GetForProfile(static_cast<Profile*>(context_));
- app_lifetime_monitor->RemoveObserver(this);
- OnChromeTerminating();
-}
-
-void AppKeepAliveService::OnAppStart(Profile* profile,
- const std::string& app_id) {
- if (profile != context_ || shut_down_)
- return;
-
- if (running_apps_.insert(app_id).second)
- chrome::IncrementKeepAliveCount();
-}
-
-void AppKeepAliveService::OnAppStop(Profile* profile,
- const std::string& app_id) {
- if (profile != context_)
- return;
-
- if (running_apps_.erase(app_id))
- chrome::DecrementKeepAliveCount();
-}
-
-void AppKeepAliveService::OnAppActivated(Profile* profile,
- const std::string& app_id) {}
-
-void AppKeepAliveService::OnAppDeactivated(Profile* profile,
- const std::string& app_id) {}
-
-void AppKeepAliveService::OnChromeTerminating() {
- shut_down_ = true;
- size_t keep_alives = running_apps_.size();
- running_apps_.clear();
-
- // In some tests, the message loop isn't running during shutdown and ending
- // the last keep alive in that case CHECKs.
- if (!base::MessageLoop::current() ||
- base::MessageLoop::current()->is_running()) {
- while (keep_alives--)
- chrome::DecrementKeepAliveCount();
- }
-}
-
-} // namespace apps
diff --git a/apps/app_keep_alive_service.h b/apps/app_keep_alive_service.h
deleted file mode 100644
index d3fecf9..0000000
--- a/apps/app_keep_alive_service.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APPS_APP_KEEP_ALIVE_SERVICE_H_
-#define APPS_APP_KEEP_ALIVE_SERVICE_H_
-
-#include "apps/app_lifetime_monitor.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
-
-namespace apps {
-
-class AppKeepAliveService : public BrowserContextKeyedService,
- public AppLifetimeMonitor::Observer {
- public:
- AppKeepAliveService(content::BrowserContext* context);
- virtual ~AppKeepAliveService();
- virtual void Shutdown() OVERRIDE;
-
- // AppLifetimeMonitor::Observer:
- virtual void OnAppStart(Profile* profile, const std::string& app_id) OVERRIDE;
- virtual void OnAppStop(Profile* profile, const std::string& app_id) OVERRIDE;
- virtual void OnAppActivated(Profile* profile,
- const std::string& app_id) OVERRIDE;
- virtual void OnAppDeactivated(Profile* profile,
- const std::string& app_id) OVERRIDE;
- virtual void OnChromeTerminating() OVERRIDE;
-
- private:
- content::BrowserContext* context_;
- std::set<std::string> running_apps_;
- bool shut_down_;
-
- DISALLOW_COPY_AND_ASSIGN(AppKeepAliveService);
-};
-
-} // namespace apps
-
-#endif // APPS_APP_KEEP_ALIVE_SERVICE_H_
diff --git a/apps/app_keep_alive_service_factory.cc b/apps/app_keep_alive_service_factory.cc
deleted file mode 100644
index 5afe050..0000000
--- a/apps/app_keep_alive_service_factory.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "apps/app_keep_alive_service_factory.h"
-
-#include "apps/app_keep_alive_service.h"
-#include "apps/app_lifetime_monitor_factory.h"
-#include "apps/app_window_registry.h"
-#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
-#include "extensions/browser/extensions_browser_client.h"
-
-namespace apps {
-
-// static
-AppKeepAliveServiceFactory* AppKeepAliveServiceFactory::GetInstance() {
- return Singleton<AppKeepAliveServiceFactory>::get();
-}
-
-AppKeepAliveServiceFactory::AppKeepAliveServiceFactory()
- : BrowserContextKeyedServiceFactory(
- "AppKeepAliveService",
- BrowserContextDependencyManager::GetInstance()) {
- DependsOn(AppLifetimeMonitorFactory::GetInstance());
-}
-
-AppKeepAliveServiceFactory::~AppKeepAliveServiceFactory() {}
-
-BrowserContextKeyedService* AppKeepAliveServiceFactory::BuildServiceInstanceFor(
- content::BrowserContext* context) const {
- return new AppKeepAliveService(context);
-}
-
-bool AppKeepAliveServiceFactory::ServiceIsCreatedWithBrowserContext() const {
- return true;
-}
-
-content::BrowserContext* AppKeepAliveServiceFactory::GetBrowserContextToUse(
- content::BrowserContext* context) const {
- return extensions::ExtensionsBrowserClient::Get()->
- GetOriginalContext(context);
-}
-
-bool AppKeepAliveServiceFactory::ServiceIsNULLWhileTesting() const {
- return true;
-}
-
-} // namespace apps
diff --git a/apps/app_keep_alive_service_factory.h b/apps/app_keep_alive_service_factory.h
deleted file mode 100644
index 32575d9..0000000
--- a/apps/app_keep_alive_service_factory.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APPS_APP_KEEP_ALIVE_SERVICE_FACTORY_H_
-#define APPS_APP_KEEP_ALIVE_SERVICE_FACTORY_H_
-
-#include "base/memory/singleton.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h"
-
-namespace apps {
-
-class AppKeepAliveService;
-
-class AppKeepAliveServiceFactory : public BrowserContextKeyedServiceFactory {
- public:
- static AppKeepAliveServiceFactory* GetInstance();
-
- private:
- friend struct DefaultSingletonTraits<AppKeepAliveServiceFactory>;
-
- AppKeepAliveServiceFactory();
- virtual ~AppKeepAliveServiceFactory();
-
- // BrowserContextKeyedServiceFactory:
- virtual BrowserContextKeyedService* BuildServiceInstanceFor(
- content::BrowserContext* context) const OVERRIDE;
- virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE;
- virtual content::BrowserContext* GetBrowserContextToUse(
- content::BrowserContext* context) const OVERRIDE;
- virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
-};
-
-} // namespace apps
-
-#endif // APPS_APP_KEEP_ALIVE_SERVICE_FACTORY_H_
diff --git a/apps/app_keep_alive_service_unittest.cc b/apps/app_keep_alive_service_unittest.cc
deleted file mode 100644
index 1e4074c..0000000
--- a/apps/app_keep_alive_service_unittest.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "apps/app_keep_alive_service.h"
-#include "apps/app_keep_alive_service_factory.h"
-#include "chrome/browser/lifetime/application_lifetime.h"
-#include "chrome/test/base/testing_profile.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-#if !defined(OS_ANDROID)
-
-class AppKeepAliveServiceUnitTest : public testing::Test {
- protected:
- virtual void SetUp() OVERRIDE {
- testing::Test::SetUp();
- service_.reset(new apps::AppKeepAliveService(&profile_));
- }
-
- virtual void TearDown() OVERRIDE {
- while (chrome::WillKeepAlive())
- chrome::DecrementKeepAliveCount();
- testing::Test::TearDown();
- }
-
- TestingProfile profile_;
- scoped_ptr<apps::AppKeepAliveService> service_;
-};
-
-TEST_F(AppKeepAliveServiceUnitTest, Basic) {
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStop(&profile_, "foo");
- EXPECT_FALSE(chrome::WillKeepAlive());
- service_->Shutdown();
- EXPECT_FALSE(chrome::WillKeepAlive());
-}
-
-// Test that apps running in different profiles are ignored.
-TEST_F(AppKeepAliveServiceUnitTest, DifferentProfile) {
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStart(NULL, "foo");
- EXPECT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStop(NULL, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStop(&profile_, "foo");
- EXPECT_FALSE(chrome::WillKeepAlive());
- service_->Shutdown();
- EXPECT_FALSE(chrome::WillKeepAlive());
-}
-
-// Test that OnAppStop without a prior corresponding OnAppStart is ignored.
-TEST_F(AppKeepAliveServiceUnitTest, StopAppBeforeOpening) {
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStop(&profile_, "foo");
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStop(&profile_, "foo");
- EXPECT_FALSE(chrome::WillKeepAlive());
- service_->Shutdown();
- EXPECT_FALSE(chrome::WillKeepAlive());
-}
-
-// Test that OnAppStart for an app that has already started is ignored.
-TEST_F(AppKeepAliveServiceUnitTest, StartMoreThanOnce) {
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStop(&profile_, "foo");
- EXPECT_FALSE(chrome::WillKeepAlive());
- service_->Shutdown();
- EXPECT_FALSE(chrome::WillKeepAlive());
-}
-
-// Test that OnAppStart is ignored after the service has been shut down.
-TEST_F(AppKeepAliveServiceUnitTest, StartAfterShutdown) {
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->Shutdown();
- service_->OnAppStart(&profile_, "foo");
- EXPECT_FALSE(chrome::WillKeepAlive());
-}
-
-TEST_F(AppKeepAliveServiceUnitTest, MultipleApps) {
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "bar");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStop(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStop(&profile_, "bar");
- EXPECT_FALSE(chrome::WillKeepAlive());
- service_->Shutdown();
- EXPECT_FALSE(chrome::WillKeepAlive());
-}
-
-// Test that all keep alives are ended when OnChromeTerminating is called.
-TEST_F(AppKeepAliveServiceUnitTest, ChromeTerminateWithAppsStarted) {
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "bar");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnChromeTerminating();
- EXPECT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStop(&profile_, "foo");
- service_->OnAppStop(&profile_, "bar");
- EXPECT_FALSE(chrome::WillKeepAlive());
- service_->Shutdown();
- EXPECT_FALSE(chrome::WillKeepAlive());
-}
-
-// Test that all keep alives are ended when Shutdown is called.
-TEST_F(AppKeepAliveServiceUnitTest, ProfileShutdownWithAppsStarted) {
- ASSERT_FALSE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "foo");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->OnAppStart(&profile_, "bar");
- EXPECT_TRUE(chrome::WillKeepAlive());
- service_->Shutdown();
- EXPECT_FALSE(chrome::WillKeepAlive());
-}
-#endif
diff --git a/apps/apps.gypi b/apps/apps.gypi
index 3b780ab..cb317ac 100644
--- a/apps/apps.gypi
+++ b/apps/apps.gypi
@@ -23,10 +23,6 @@
'<(grit_out_dir)',
],
'sources': [
- 'app_keep_alive_service.cc',
- 'app_keep_alive_service.h',
- 'app_keep_alive_service_factory.cc',
- 'app_keep_alive_service_factory.h',
'app_lifetime_monitor.cc',
'app_lifetime_monitor.h',
'app_lifetime_monitor_factory.cc',
diff --git a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
index e8523c1..5e58b26 100644
--- a/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
+++ b/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
-#include "apps/app_keep_alive_service_factory.h"
#include "apps/app_load_service_factory.h"
#include "apps/app_restore_service_factory.h"
#include "apps/app_window_geometry_cache.h"
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index fcf5024..ac8d689 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -524,7 +524,6 @@
},
},
'sources': [
- '../apps/app_keep_alive_service_unittest.cc',
'../apps/app_shim/app_shim_host_mac_unittest.cc',
'../apps/app_shim/extension_app_shim_handler_mac_unittest.cc',
'../apps/app_window_geometry_cache_unittest.cc',