OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
6 #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 #include <string> | 12 #include <string> |
11 | 13 |
12 #include "base/callback.h" | 14 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
16 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
17 #include "components/keyed_service/core/keyed_service.h" | 20 #include "components/keyed_service/core/keyed_service.h" |
18 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
20 #include "extensions/browser/event_page_tracker.h" | 23 #include "extensions/browser/event_page_tracker.h" |
21 #include "extensions/browser/extension_registry_observer.h" | 24 #include "extensions/browser/extension_registry_observer.h" |
22 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
23 #include "extensions/common/view_type.h" | 26 #include "extensions/common/view_type.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // called regularly. | 124 // called regularly. |
122 void KeepaliveImpulse(const Extension* extension); | 125 void KeepaliveImpulse(const Extension* extension); |
123 | 126 |
124 // Triggers a keepalive impulse for a plugin (e.g NaCl). | 127 // Triggers a keepalive impulse for a plugin (e.g NaCl). |
125 static void OnKeepaliveFromPlugin(int render_process_id, | 128 static void OnKeepaliveFromPlugin(int render_process_id, |
126 int render_frame_id, | 129 int render_frame_id, |
127 const std::string& extension_id); | 130 const std::string& extension_id); |
128 | 131 |
129 // Handles a response to the ShouldSuspend message, used for lazy background | 132 // Handles a response to the ShouldSuspend message, used for lazy background |
130 // pages. | 133 // pages. |
131 void OnShouldSuspendAck(const std::string& extension_id, uint64 sequence_id); | 134 void OnShouldSuspendAck(const std::string& extension_id, |
| 135 uint64_t sequence_id); |
132 | 136 |
133 // Same as above, for the Suspend message. | 137 // Same as above, for the Suspend message. |
134 void OnSuspendAck(const std::string& extension_id); | 138 void OnSuspendAck(const std::string& extension_id); |
135 | 139 |
136 // Tracks network requests for a given RenderFrameHost, used to know | 140 // Tracks network requests for a given RenderFrameHost, used to know |
137 // when network activity is idle for lazy background pages. | 141 // when network activity is idle for lazy background pages. |
138 void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host, | 142 void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host, |
139 uint64 request_id); | 143 uint64_t request_id); |
140 void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host, | 144 void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host, |
141 uint64 request_id); | 145 uint64_t request_id); |
142 | 146 |
143 // Prevents |extension|'s background page from being closed and sends the | 147 // Prevents |extension|'s background page from being closed and sends the |
144 // onSuspendCanceled() event to it. | 148 // onSuspendCanceled() event to it. |
145 void CancelSuspend(const Extension* extension); | 149 void CancelSuspend(const Extension* extension); |
146 | 150 |
147 // Called on shutdown to close our extension hosts. | 151 // Called on shutdown to close our extension hosts. |
148 void CloseBackgroundHosts(); | 152 void CloseBackgroundHosts(); |
149 | 153 |
150 // Sets callbacks for testing keepalive impulse behavior. | 154 // Sets callbacks for testing keepalive impulse behavior. |
151 using ImpulseCallbackForTesting = | 155 using ImpulseCallbackForTesting = |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // Internal implementation of DecrementLazyKeepaliveCount with an | 255 // Internal implementation of DecrementLazyKeepaliveCount with an |
252 // |extension_id| known to have a lazy background page. | 256 // |extension_id| known to have a lazy background page. |
253 void DecrementLazyKeepaliveCount(const std::string& extension_id); | 257 void DecrementLazyKeepaliveCount(const std::string& extension_id); |
254 | 258 |
255 // Checks if keepalive impulses have occured, and adjusts keep alive count. | 259 // Checks if keepalive impulses have occured, and adjusts keep alive count. |
256 void OnKeepaliveImpulseCheck(); | 260 void OnKeepaliveImpulseCheck(); |
257 | 261 |
258 // These are called when the extension transitions between idle and active. | 262 // These are called when the extension transitions between idle and active. |
259 // They control the process of closing the background page when idle. | 263 // They control the process of closing the background page when idle. |
260 void OnLazyBackgroundPageIdle(const std::string& extension_id, | 264 void OnLazyBackgroundPageIdle(const std::string& extension_id, |
261 uint64 sequence_id); | 265 uint64_t sequence_id); |
262 void OnLazyBackgroundPageActive(const std::string& extension_id); | 266 void OnLazyBackgroundPageActive(const std::string& extension_id); |
263 void CloseLazyBackgroundPageNow(const std::string& extension_id, | 267 void CloseLazyBackgroundPageNow(const std::string& extension_id, |
264 uint64 sequence_id); | 268 uint64_t sequence_id); |
265 | 269 |
266 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); | 270 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); |
267 | 271 |
268 // Unregister RenderFrameHosts and clear background page data for an extension | 272 // Unregister RenderFrameHosts and clear background page data for an extension |
269 // which has been unloaded. | 273 // which has been unloaded. |
270 void UnregisterExtension(const std::string& extension_id); | 274 void UnregisterExtension(const std::string& extension_id); |
271 | 275 |
272 // Clears background page data for this extension. | 276 // Clears background page data for this extension. |
273 void ClearBackgroundPageData(const std::string& extension_id); | 277 void ClearBackgroundPageData(const std::string& extension_id); |
274 | 278 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // lazy background process. | 312 // lazy background process. |
309 // | 313 // |
310 // Any interruption obtains a new ID by incrementing | 314 // Any interruption obtains a new ID by incrementing |
311 // last_background_close_sequence_id_ and storing it in background_page_data_ | 315 // last_background_close_sequence_id_ and storing it in background_page_data_ |
312 // for a particular extension. Callbacks and round-trip IPC messages store the | 316 // for a particular extension. Callbacks and round-trip IPC messages store the |
313 // value of the extension's close_sequence_id at the beginning of the process. | 317 // value of the extension's close_sequence_id at the beginning of the process. |
314 // Thus comparisons can be done to halt when IDs no longer match. | 318 // Thus comparisons can be done to halt when IDs no longer match. |
315 // | 319 // |
316 // This counter provides unique IDs even when BackgroundPageData objects are | 320 // This counter provides unique IDs even when BackgroundPageData objects are |
317 // reset. | 321 // reset. |
318 uint64 last_background_close_sequence_id_; | 322 uint64_t last_background_close_sequence_id_; |
319 | 323 |
320 // Tracks pending network requests by opaque ID. This is used to ensure proper | 324 // Tracks pending network requests by opaque ID. This is used to ensure proper |
321 // keepalive counting in response to request status updates; e.g., if an | 325 // keepalive counting in response to request status updates; e.g., if an |
322 // extension URLRequest is constructed and then destroyed without ever | 326 // extension URLRequest is constructed and then destroyed without ever |
323 // starting, we can receive a completion notification without a corresponding | 327 // starting, we can receive a completion notification without a corresponding |
324 // start notification. In that case we want to avoid decrementing keepalive. | 328 // start notification. In that case we want to avoid decrementing keepalive. |
325 std::set<int> pending_network_requests_; | 329 std::set<int> pending_network_requests_; |
326 | 330 |
327 // Must be last member, see doc on WeakPtrFactory. | 331 // Must be last member, see doc on WeakPtrFactory. |
328 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; | 332 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
329 | 333 |
330 DISALLOW_COPY_AND_ASSIGN(ProcessManager); | 334 DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
331 }; | 335 }; |
332 | 336 |
333 } // namespace extensions | 337 } // namespace extensions |
334 | 338 |
335 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 339 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
OLD | NEW |