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

Unified Diff: chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc

Issue 406483004: Initial implementation of API WakeLock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc
diff --git a/chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc b/chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a9c330ee0c70912d3eb8f6928a759bffe7ed25ea
--- /dev/null
+++ b/chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2014 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 "chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/wake_lock/chrome_wake_lock_permission_context.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+
+namespace {
+
+class Service : public KeyedService {
+ public:
+ explicit Service(Profile* profile) {
+ context_ = new ChromeWakeLockPermissionContext(profile);
+ }
+
+ ChromeWakeLockPermissionContext* context() {
+ return context_.get();
+ }
+
+ virtual void Shutdown() OVERRIDE {
+ context()->ShutdownOnUIThread();
+ }
+
+ private:
+ scoped_refptr<ChromeWakeLockPermissionContext> context_;
+
+ DISALLOW_COPY_AND_ASSIGN(Service);
+};
+
+} // namespace
+
+// static
+ChromeWakeLockPermissionContext*
+ChromeWakeLockPermissionContextFactory::GetForProfile(Profile* profile) {
+ return static_cast<Service*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true))->context();
+}
+
+// static
+ChromeWakeLockPermissionContextFactory*
+ChromeWakeLockPermissionContextFactory::GetInstance() {
+ return Singleton<ChromeWakeLockPermissionContextFactory>::get();
+}
+
+ChromeWakeLockPermissionContextFactory::
+ChromeWakeLockPermissionContextFactory()
+ : BrowserContextKeyedServiceFactory(
+ "ChromeWakeLockPermissionContext",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+ChromeWakeLockPermissionContextFactory::
+~ChromeWakeLockPermissionContextFactory() {
+}
+
+KeyedService*
+ChromeWakeLockPermissionContextFactory::BuildServiceInstanceFor(
+ content::BrowserContext* profile) const {
+ return new Service(static_cast<Profile*>(profile));
+}

Powered by Google App Engine
This is Rietveld 408576698