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

Side by Side Diff: chrome/browser/extensions/extension_process_manager.h

Issue 9562017: Keep lazy background page alive while there are pending network requests or (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 bool HasExtensionHost(ExtensionHost* host) const; 90 bool HasExtensionHost(ExtensionHost* host) const;
91 91
92 // Getter and setter for the lazy background page's keepalive count. This is 92 // Getter and setter for the lazy background page's keepalive count. This is
93 // the count of how many outstanding "things" are keeping the page alive. 93 // the count of how many outstanding "things" are keeping the page alive.
94 // When this reaches 0, we will begin the process of shutting down the page. 94 // When this reaches 0, we will begin the process of shutting down the page.
95 // "Things" include pending events, resource loads, and API calls. 95 // "Things" include pending events, resource loads, and API calls.
96 int GetLazyKeepaliveCount(const Extension* extension); 96 int GetLazyKeepaliveCount(const Extension* extension);
97 int IncrementLazyKeepaliveCount(const Extension* extension); 97 int IncrementLazyKeepaliveCount(const Extension* extension);
98 int DecrementLazyKeepaliveCount(const Extension* extension); 98 int DecrementLazyKeepaliveCount(const Extension* extension);
99 99
100 // These are called when the extension transitions between idle and active. 100 // Handles a response to the ShouldClose message, used for lazy background
101 // They control the process of closing the background page when idle.
102 void OnLazyBackgroundPageIdle(const std::string& extension_id);
103 void OnLazyBackgroundPageActive(const std::string& extension_id);
104
105 // Handle a response to the ShouldClose message, used for lazy background
106 // pages. 101 // pages.
107 void OnShouldCloseAck(const std::string& extension_id, int sequence_id); 102 void OnShouldCloseAck(const std::string& extension_id, int sequence_id);
108 103
104 // Tracks network requests for a given RenderViewHost, used to know
105 // when network activity is idle for lazy background pages.
106 void OnNetworkRequestStarted(RenderViewHost* render_view_host);
107 void OnNetworkRequestDone(RenderViewHost* render_view_host);
108
109 typedef std::set<ExtensionHost*> ExtensionHostSet; 109 typedef std::set<ExtensionHost*> ExtensionHostSet;
110 typedef ExtensionHostSet::const_iterator const_iterator; 110 typedef ExtensionHostSet::const_iterator const_iterator;
111 const_iterator begin() const { return all_hosts_.begin(); } 111 const_iterator begin() const { return all_hosts_.begin(); }
112 const_iterator end() const { return all_hosts_.end(); } 112 const_iterator end() const { return all_hosts_.end(); }
113 113
114 protected: 114 protected:
115 explicit ExtensionProcessManager(Profile* profile); 115 explicit ExtensionProcessManager(Profile* profile);
116 116
117 // Called just after |host| is created so it can be registered in our lists. 117 // Called just after |host| is created so it can be registered in our lists.
118 void OnExtensionHostCreated(ExtensionHost* host, bool is_background); 118 void OnExtensionHostCreated(ExtensionHost* host, bool is_background);
(...skipping 18 matching lines...) Expand all
137 // The set of running viewless background extensions. 137 // The set of running viewless background extensions.
138 ExtensionHostSet background_hosts_; 138 ExtensionHostSet background_hosts_;
139 139
140 // A SiteInstance related to the SiteInstance for all extensions in 140 // A SiteInstance related to the SiteInstance for all extensions in
141 // this profile. We create it in such a way that a new 141 // this profile. We create it in such a way that a new
142 // browsing instance is created. This controls process grouping. 142 // browsing instance is created. This controls process grouping.
143 scoped_refptr<content::SiteInstance> site_instance_; 143 scoped_refptr<content::SiteInstance> site_instance_;
144 144
145 private: 145 private:
146 // Contains all extension-related RenderViewHost instances for all extensions. 146 // Contains all extension-related RenderViewHost instances for all extensions.
147 typedef std::set<RenderViewHost*> RenderViewHostSet; 147 // We also keep a cache of the host's view type, because that information
148 RenderViewHostSet all_extension_views_; 148 // is not accessible at registration/deregistration time.
149 typedef std::map<RenderViewHost*, content::ViewType> ExtensionRenderViews;
Yoyo Zhou 2012/03/02 03:10:46 I think this typename should have "Map".
Matt Perry 2012/03/02 20:25:21 I disagree. I don't like putting container types i
Yoyo Zhou 2012/03/02 20:31:58 I don't think that's a significant cost. As someon
150 ExtensionRenderViews all_extension_views_;
149 151
150 // Close the given |host| iff it's a background page. 152 // Close the given |host| iff it's a background page.
151 void CloseBackgroundHost(ExtensionHost* host); 153 void CloseBackgroundHost(ExtensionHost* host);
152 154
153 // Excludes background page. 155 // These are called when the extension transitions between idle and active.
154 bool HasVisibleViews(const std::string& extension_id); 156 // They control the process of closing the background page when idle.
157 void OnLazyBackgroundPageIdle(const std::string& extension_id);
158 void OnLazyBackgroundPageActive(const std::string& extension_id);
159
160 // Updates a potentially-registered RenderViewHost once it has been
161 // associated with a WebContents. This allows us to gather information that
162 // was not available when the host was first registered.
163 void UpdateRegisteredRenderView(RenderViewHost* render_view_host);
155 164
156 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager); 165 DISALLOW_COPY_AND_ASSIGN(ExtensionProcessManager);
157 }; 166 };
158 167
159 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ 168 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698