| 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> |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host); | 118 void OnNetworkRequestStarted(content::RenderFrameHost* render_frame_host); |
| 119 void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host); | 119 void OnNetworkRequestDone(content::RenderFrameHost* render_frame_host); |
| 120 | 120 |
| 121 // Prevents |extension|'s background page from being closed and sends the | 121 // Prevents |extension|'s background page from being closed and sends the |
| 122 // onSuspendCanceled() event to it. | 122 // onSuspendCanceled() event to it. |
| 123 void CancelSuspend(const Extension* extension); | 123 void CancelSuspend(const Extension* extension); |
| 124 | 124 |
| 125 // Ensures background hosts are loaded for a new browser window. | 125 // Ensures background hosts are loaded for a new browser window. |
| 126 void OnBrowserWindowReady(); | 126 void OnBrowserWindowReady(); |
| 127 | 127 |
| 128 // Notifies the ProcessManager that a BrowserContext is fully initialized. |
| 129 // A BrowserContext might be initialized asynchronously (in parallel with |
| 130 // extension system startup). The ProcessManager needs to know when that |
| 131 // initialization is complete so it can load deferred background pages. |
| 132 // (See NOTIFICATION_PROFILE_CREATED in Chrome and IsContextValid() in |
| 133 // ExtensionsBrowserClient). |
| 134 void OnBrowserContextValid(content::BrowserContext* context); |
| 135 |
| 128 // Gets the BrowserContext associated with site_instance_ and all other | 136 // Gets the BrowserContext associated with site_instance_ and all other |
| 129 // related SiteInstances. | 137 // related SiteInstances. |
| 130 content::BrowserContext* GetBrowserContext() const; | 138 content::BrowserContext* GetBrowserContext() const; |
| 131 | 139 |
| 132 // Sets callbacks for testing keepalive impulse behavior. | 140 // Sets callbacks for testing keepalive impulse behavior. |
| 133 typedef base::Callback<void(const std::string& extension_id)> | 141 typedef base::Callback<void(const std::string& extension_id)> |
| 134 ImpulseCallbackForTesting; | 142 ImpulseCallbackForTesting; |
| 135 void SetKeepaliveImpulseCallbackForTesting( | 143 void SetKeepaliveImpulseCallbackForTesting( |
| 136 const ImpulseCallbackForTesting& callback); | 144 const ImpulseCallbackForTesting& callback); |
| 137 void SetKeepaliveImpulseDecrementCallbackForTesting( | 145 void SetKeepaliveImpulseDecrementCallbackForTesting( |
| 138 const ImpulseCallbackForTesting& callback); | 146 const ImpulseCallbackForTesting& callback); |
| 139 | 147 |
| 140 // Creates an incognito-context instance for tests. Tests for non-incognito | 148 // Creates an incognito-context instance for tests. Tests for non-incognito |
| 141 // contexts can just use Create() above. | 149 // contexts can just use Create() above. |
| 142 static ProcessManager* CreateIncognitoForTesting( | 150 static ProcessManager* CreateIncognitoForTesting( |
| 143 content::BrowserContext* incognito_context, | 151 content::BrowserContext* incognito_context, |
| 144 content::BrowserContext* original_context, | 152 content::BrowserContext* original_context, |
| 145 ProcessManager* original_manager); | 153 ProcessManager* original_manager); |
| 146 | 154 |
| 155 bool startup_background_hosts_created_for_test() const { |
| 156 return startup_background_hosts_created_; |
| 157 } |
| 158 |
| 147 protected: | 159 protected: |
| 148 // If |context| is incognito pass the master context as |original_context|. | 160 // If |context| is incognito pass the master context as |original_context|. |
| 149 // Otherwise pass the same context for both. | 161 // Otherwise pass the same context for both. |
| 150 ProcessManager(content::BrowserContext* context, | 162 ProcessManager(content::BrowserContext* context, |
| 151 content::BrowserContext* original_context); | 163 content::BrowserContext* original_context); |
| 152 | 164 |
| 153 // Called on browser shutdown to close our extension hosts. | 165 // Called on browser shutdown to close our extension hosts. |
| 154 void CloseBackgroundHosts(); | 166 void CloseBackgroundHosts(); |
| 155 | 167 |
| 156 // content::NotificationObserver: | 168 // content::NotificationObserver: |
| 157 virtual void Observe(int type, | 169 virtual void Observe(int type, |
| 158 const content::NotificationSource& source, | 170 const content::NotificationSource& source, |
| 159 const content::NotificationDetails& details) OVERRIDE; | 171 const content::NotificationDetails& details) OVERRIDE; |
| 160 | 172 |
| 161 // Load all background pages once the profile data is ready and the pages | 173 // Loads all background pages for a BrowserContext if everything is ready. |
| 162 // should be loaded. | 174 void MaybeCreateBackgroundHostsForStartup(); |
| 163 void CreateBackgroundHostsForProfileStartup(); | |
| 164 | 175 |
| 165 content::NotificationRegistrar registrar_; | 176 content::NotificationRegistrar registrar_; |
| 166 | 177 |
| 167 // The set of ExtensionHosts running viewless background extensions. | 178 // The set of ExtensionHosts running viewless background extensions. |
| 168 ExtensionHostSet background_hosts_; | 179 ExtensionHostSet background_hosts_; |
| 169 | 180 |
| 170 // A SiteInstance related to the SiteInstance for all extensions in | 181 // A SiteInstance related to the SiteInstance for all extensions in |
| 171 // this profile. We create it in such a way that a new | 182 // this profile. We create it in such a way that a new |
| 172 // browsing instance is created. This controls process grouping. | 183 // browsing instance is created. This controls process grouping. |
| 173 scoped_refptr<content::SiteInstance> site_instance_; | 184 scoped_refptr<content::SiteInstance> site_instance_; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 ObserverList<ProcessManagerObserver> observer_list_; | 258 ObserverList<ProcessManagerObserver> observer_list_; |
| 248 | 259 |
| 249 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; | 260 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; |
| 250 | 261 |
| 251 DISALLOW_COPY_AND_ASSIGN(ProcessManager); | 262 DISALLOW_COPY_AND_ASSIGN(ProcessManager); |
| 252 }; | 263 }; |
| 253 | 264 |
| 254 } // namespace extensions | 265 } // namespace extensions |
| 255 | 266 |
| 256 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ | 267 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ |
| OLD | NEW |