OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_CHROMEOS_POWER_EXTENSION_EVENT_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_EXTENSION_EVENT_OBSERVER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POWER_EXTENSION_EVENT_OBSERVER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POWER_EXTENSION_EVENT_OBSERVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <set> | 11 #include <set> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/cancelable_callback.h" | 15 #include "base/cancelable_callback.h" |
15 #include "base/containers/scoped_ptr_hash_map.h" | 16 #include "base/containers/scoped_ptr_hash_map.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "chromeos/dbus/power_manager_client.h" | 20 #include "chromeos/dbus/power_manager_client.h" |
21 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
25 #include "extensions/browser/extension_host_observer.h" | 25 #include "extensions/browser/extension_host_observer.h" |
26 #include "extensions/browser/process_manager_observer.h" | 26 #include "extensions/browser/process_manager_observer.h" |
27 | 27 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 explicit TestApi(base::WeakPtr<ExtensionEventObserver> parent); | 61 explicit TestApi(base::WeakPtr<ExtensionEventObserver> parent); |
62 | 62 |
63 base::WeakPtr<ExtensionEventObserver> parent_; | 63 base::WeakPtr<ExtensionEventObserver> parent_; |
64 | 64 |
65 DISALLOW_COPY_AND_ASSIGN(TestApi); | 65 DISALLOW_COPY_AND_ASSIGN(TestApi); |
66 }; | 66 }; |
67 | 67 |
68 ExtensionEventObserver(); | 68 ExtensionEventObserver(); |
69 ~ExtensionEventObserver() override; | 69 ~ExtensionEventObserver() override; |
70 | 70 |
71 scoped_ptr<TestApi> CreateTestApi(); | 71 std::unique_ptr<TestApi> CreateTestApi(); |
72 | 72 |
73 // Called by the WakeOnWifiManager to control whether the | 73 // Called by the WakeOnWifiManager to control whether the |
74 // ExtensionEventObserver should or should not delay the system suspend. | 74 // ExtensionEventObserver should or should not delay the system suspend. |
75 void SetShouldDelaySuspend(bool should_delay); | 75 void SetShouldDelaySuspend(bool should_delay); |
76 | 76 |
77 // content::NotificationObserver override. | 77 // content::NotificationObserver override. |
78 void Observe(int type, | 78 void Observe(int type, |
79 const content::NotificationSource& source, | 79 const content::NotificationSource& source, |
80 const content::NotificationDetails& details) override; | 80 const content::NotificationDetails& details) override; |
81 | 81 |
(...skipping 27 matching lines...) Expand all Loading... |
109 // Called when the system is about to perform a regular suspend or a dark | 109 // Called when the system is about to perform a regular suspend or a dark |
110 // suspend. | 110 // suspend. |
111 void OnSuspendImminent(bool dark_suspend); | 111 void OnSuspendImminent(bool dark_suspend); |
112 | 112 |
113 // Reports readiness to suspend to the PowerManagerClient if a suspend is | 113 // Reports readiness to suspend to the PowerManagerClient if a suspend is |
114 // pending and there are no outstanding events keeping the system awake. | 114 // pending and there are no outstanding events keeping the system awake. |
115 void MaybeReportSuspendReadiness(); | 115 void MaybeReportSuspendReadiness(); |
116 | 116 |
117 struct KeepaliveSources; | 117 struct KeepaliveSources; |
118 base::ScopedPtrHashMap<const extensions::ExtensionHost*, | 118 base::ScopedPtrHashMap<const extensions::ExtensionHost*, |
119 scoped_ptr<KeepaliveSources>> keepalive_sources_; | 119 std::unique_ptr<KeepaliveSources>> |
| 120 keepalive_sources_; |
120 | 121 |
121 std::set<Profile*> active_profiles_; | 122 std::set<Profile*> active_profiles_; |
122 | 123 |
123 bool should_delay_suspend_; | 124 bool should_delay_suspend_; |
124 bool suspend_is_pending_; | 125 bool suspend_is_pending_; |
125 int suspend_keepalive_count_; | 126 int suspend_keepalive_count_; |
126 base::Closure power_manager_callback_; | 127 base::Closure power_manager_callback_; |
127 base::CancelableClosure suspend_readiness_callback_; | 128 base::CancelableClosure suspend_readiness_callback_; |
128 | 129 |
129 content::NotificationRegistrar registrar_; | 130 content::NotificationRegistrar registrar_; |
130 | 131 |
131 base::WeakPtrFactory<ExtensionEventObserver> weak_factory_; | 132 base::WeakPtrFactory<ExtensionEventObserver> weak_factory_; |
132 | 133 |
133 DISALLOW_COPY_AND_ASSIGN(ExtensionEventObserver); | 134 DISALLOW_COPY_AND_ASSIGN(ExtensionEventObserver); |
134 }; | 135 }; |
135 | 136 |
136 } // namespace chromeos | 137 } // namespace chromeos |
137 | 138 |
138 #endif // CHROME_BROWSER_CHROMEOS_POWER_EXTENSION_EVENT_OBSERVER_H_ | 139 #endif // CHROME_BROWSER_CHROMEOS_POWER_EXTENSION_EVENT_OBSERVER_H_ |
OLD | NEW |