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

Side by Side Diff: extensions/browser/process_manager.h

Issue 1096313003: Create interface "EventPageTracker" for checking an extension's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 80col rewrap Created 5 years, 7 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
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 21 matching lines...) Expand all
78 // Incognito. 80 // Incognito.
79 virtual bool CreateBackgroundHost(const Extension* extension, 81 virtual bool CreateBackgroundHost(const Extension* extension,
80 const GURL& url); 82 const GURL& url);
81 83
82 // Creates background hosts if the embedder is ready and they are not already 84 // Creates background hosts if the embedder is ready and they are not already
83 // loaded. 85 // loaded.
84 void MaybeCreateStartupBackgroundHosts(); 86 void MaybeCreateStartupBackgroundHosts();
85 87
86 // Gets the ExtensionHost for the background page for an extension, or null if 88 // Gets the ExtensionHost for the background page for an extension, or null if
87 // the extension isn't running or doesn't have a background page. 89 // the extension isn't running or doesn't have a background page.
88 ExtensionHost* GetBackgroundHostForExtension(const std::string& extension_id); 90 virtual ExtensionHost* GetBackgroundHostForExtension(
not at google - send to devlin 2015/04/28 21:35:11 Doesn't need to be virtual anymore.
91 const std::string& extension_id);
89 92
90 // Returns true if the (lazy) background host for the given extension has 93 // Returns true if the (lazy) background host for the given extension has
91 // already been sent the unload event and is shutting down. 94 // already been sent the unload event and is shutting down.
92 bool IsBackgroundHostClosing(const std::string& extension_id); 95 bool IsBackgroundHostClosing(const std::string& extension_id);
93 96
94 // Returns the extension associated with the specified RenderFrameHost/ 97 // Returns the extension associated with the specified RenderFrameHost/
95 // WebContents, or null. 98 // WebContents, or null.
96 const Extension* GetExtensionForRenderFrameHost( 99 const Extension* GetExtensionForRenderFrameHost(
97 content::RenderFrameHost* render_frame_host); 100 content::RenderFrameHost* render_frame_host);
98 const Extension* GetExtensionForWebContents( 101 const Extension* GetExtensionForWebContents(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void CloseBackgroundHosts(); 141 void CloseBackgroundHosts();
139 142
140 // Sets callbacks for testing keepalive impulse behavior. 143 // Sets callbacks for testing keepalive impulse behavior.
141 using ImpulseCallbackForTesting = 144 using ImpulseCallbackForTesting =
142 base::Callback<void(const std::string& extension_id)>; 145 base::Callback<void(const std::string& extension_id)>;
143 void SetKeepaliveImpulseCallbackForTesting( 146 void SetKeepaliveImpulseCallbackForTesting(
144 const ImpulseCallbackForTesting& callback); 147 const ImpulseCallbackForTesting& callback);
145 void SetKeepaliveImpulseDecrementCallbackForTesting( 148 void SetKeepaliveImpulseDecrementCallbackForTesting(
146 const ImpulseCallbackForTesting& callback); 149 const ImpulseCallbackForTesting& callback);
147 150
151 // EventPageTracker implementation.
152 bool IsEventPageSuspended(const std::string& extension_id) override;
153 bool WakeEventPage(const std::string& extension_id,
154 const base::Callback<void(bool)>& callback) override;
155
148 // Sets the time in milliseconds that an extension event page can 156 // Sets the time in milliseconds that an extension event page can
149 // be idle before it is shut down; must be > 0. 157 // be idle before it is shut down; must be > 0.
150 static void SetEventPageIdleTimeForTesting(unsigned idle_time_msec); 158 static void SetEventPageIdleTimeForTesting(unsigned idle_time_msec);
151 159
152 // Sets the time in milliseconds that an extension event page has 160 // Sets the time in milliseconds that an extension event page has
153 // between being notified of its impending unload and that unload 161 // between being notified of its impending unload and that unload
154 // happening. 162 // happening.
155 static void SetEventPageSuspendingTimeForTesting( 163 static void SetEventPageSuspendingTimeForTesting(
156 unsigned suspending_time_msec); 164 unsigned suspending_time_msec);
157 165
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 312
305 // Must be last member, see doc on WeakPtrFactory. 313 // Must be last member, see doc on WeakPtrFactory.
306 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; 314 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_;
307 315
308 DISALLOW_COPY_AND_ASSIGN(ProcessManager); 316 DISALLOW_COPY_AND_ASSIGN(ProcessManager);
309 }; 317 };
310 318
311 } // namespace extensions 319 } // namespace extensions
312 320
313 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ 321 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698