| 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 <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "extensions/browser/event_page_tracker.h" |
| 20 #include "extensions/browser/extension_registry_observer.h" | 21 #include "extensions/browser/extension_registry_observer.h" |
| 21 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
| 22 #include "extensions/common/view_type.h" | 23 #include "extensions/common/view_type.h" |
| 23 | 24 |
| 24 class GURL; | 25 class GURL; |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 class BrowserContext; | 28 class BrowserContext; |
| 28 class DevToolsAgentHost; | 29 class DevToolsAgentHost; |
| 29 class RenderFrameHost; | 30 class RenderFrameHost; |
| 30 class SiteInstance; | 31 class SiteInstance; |
| 31 class WebContents; | 32 class WebContents; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 namespace extensions { | 35 namespace extensions { |
| 35 | 36 |
| 36 class Extension; | 37 class Extension; |
| 37 class ExtensionHost; | 38 class ExtensionHost; |
| 38 class ExtensionRegistry; | 39 class ExtensionRegistry; |
| 39 class ProcessManagerObserver; | 40 class ProcessManagerObserver; |
| 40 | 41 |
| 41 // Manages dynamic state of running Chromium extensions. There is one instance | 42 // Manages dynamic state of running Chromium extensions. There is one instance |
| 42 // of this class per Profile. OTR Profiles have a separate instance that keeps | 43 // of this class per Profile. OTR Profiles have a separate instance that keeps |
| 43 // track of split-mode extensions only. | 44 // track of split-mode extensions only. |
| 44 class ProcessManager : public KeyedService, | 45 class ProcessManager : public KeyedService, |
| 45 public content::NotificationObserver, | 46 public content::NotificationObserver, |
| 46 public ExtensionRegistryObserver { | 47 public ExtensionRegistryObserver, |
| 48 public EventPageTracker { |
| 47 public: | 49 public: |
| 48 using ExtensionHostSet = std::set<extensions::ExtensionHost*>; | 50 using ExtensionHostSet = std::set<extensions::ExtensionHost*>; |
| 49 | 51 |
| 50 static ProcessManager* Get(content::BrowserContext* context); | 52 static ProcessManager* Get(content::BrowserContext* context); |
| 51 ~ProcessManager() override; | 53 ~ProcessManager() override; |
| 52 | 54 |
| 53 void RegisterRenderFrameHost(content::WebContents* web_contents, | 55 void RegisterRenderFrameHost(content::WebContents* web_contents, |
| 54 content::RenderFrameHost* render_frame_host, | 56 content::RenderFrameHost* render_frame_host, |
| 55 const Extension* extension); | 57 const Extension* extension); |
| 56 void UnregisterRenderFrameHost(content::RenderFrameHost* render_frame_host); | 58 void UnregisterRenderFrameHost(content::RenderFrameHost* render_frame_host); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 void CloseBackgroundHosts(); | 140 void CloseBackgroundHosts(); |
| 139 | 141 |
| 140 // Sets callbacks for testing keepalive impulse behavior. | 142 // Sets callbacks for testing keepalive impulse behavior. |
| 141 using ImpulseCallbackForTesting = | 143 using ImpulseCallbackForTesting = |
| 142 base::Callback<void(const std::string& extension_id)>; | 144 base::Callback<void(const std::string& extension_id)>; |
| 143 void SetKeepaliveImpulseCallbackForTesting( | 145 void SetKeepaliveImpulseCallbackForTesting( |
| 144 const ImpulseCallbackForTesting& callback); | 146 const ImpulseCallbackForTesting& callback); |
| 145 void SetKeepaliveImpulseDecrementCallbackForTesting( | 147 void SetKeepaliveImpulseDecrementCallbackForTesting( |
| 146 const ImpulseCallbackForTesting& callback); | 148 const ImpulseCallbackForTesting& callback); |
| 147 | 149 |
| 150 // EventPageTracker implementation. |
| 151 bool IsEventPageActive(const std::string& extension_id) override; |
| 152 bool WakeEventPage(const std::string& extension_id, |
| 153 const base::Callback<void(bool)>& callback) override; |
| 154 |
| 148 // Sets the time in milliseconds that an extension event page can | 155 // Sets the time in milliseconds that an extension event page can |
| 149 // be idle before it is shut down; must be > 0. | 156 // be idle before it is shut down; must be > 0. |
| 150 static void SetEventPageIdleTimeForTesting(unsigned idle_time_msec); | 157 static void SetEventPageIdleTimeForTesting(unsigned idle_time_msec); |
| 151 | 158 |
| 152 // Sets the time in milliseconds that an extension event page has | 159 // Sets the time in milliseconds that an extension event page has |
| 153 // between being notified of its impending unload and that unload | 160 // between being notified of its impending unload and that unload |
| 154 // happening. | 161 // happening. |
| 155 static void SetEventPageSuspendingTimeForTesting( | 162 static void SetEventPageSuspendingTimeForTesting( |
| 156 unsigned suspending_time_msec); | 163 unsigned suspending_time_msec); |
| 157 | 164 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 311 |
| 305 // Must be last member, see doc on WeakPtrFactory. | 312 // Must be last member, see doc on WeakPtrFactory. |
| 306 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; | 313 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
| 307 | 314 |
| 308 DISALLOW_COPY_AND_ASSIGN(ProcessManager); | 315 DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
| 309 }; | 316 }; |
| 310 | 317 |
| 311 } // namespace extensions | 318 } // namespace extensions |
| 312 | 319 |
| 313 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 320 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
| OLD | NEW |