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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/wake_lock/chrome_wake_lock_permission_context_factory.h "
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/wake_lock/chrome_wake_lock_permission_context.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10
11 namespace {
12
13 class Service : public KeyedService {
14 public:
15 explicit Service(Profile* profile) {
16 context_ = new ChromeWakeLockPermissionContext(profile);
17 }
18
19 ChromeWakeLockPermissionContext* context() {
20 return context_.get();
21 }
22
23 virtual void Shutdown() OVERRIDE {
24 context()->ShutdownOnUIThread();
25 }
26
27 private:
28 scoped_refptr<ChromeWakeLockPermissionContext> context_;
29
30 DISALLOW_COPY_AND_ASSIGN(Service);
31 };
32
33 } // namespace
34
35 // static
36 ChromeWakeLockPermissionContext*
37 ChromeWakeLockPermissionContextFactory::GetForProfile(Profile* profile) {
38 return static_cast<Service*>(
39 GetInstance()->GetServiceForBrowserContext(profile, true))->context();
40 }
41
42 // static
43 ChromeWakeLockPermissionContextFactory*
44 ChromeWakeLockPermissionContextFactory::GetInstance() {
45 return Singleton<ChromeWakeLockPermissionContextFactory>::get();
46 }
47
48 ChromeWakeLockPermissionContextFactory::
49 ChromeWakeLockPermissionContextFactory()
50 : BrowserContextKeyedServiceFactory(
51 "ChromeWakeLockPermissionContext",
52 BrowserContextDependencyManager::GetInstance()) {
53 }
54
55 ChromeWakeLockPermissionContextFactory::
56 ~ChromeWakeLockPermissionContextFactory() {
57 }
58
59 KeyedService*
60 ChromeWakeLockPermissionContextFactory::BuildServiceInstanceFor(
61 content::BrowserContext* profile) const {
62 return new Service(static_cast<Profile*>(profile));
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698