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

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

Issue 995983002: Make LoadMonitoringExtensionHostQueue remove itself as an ExtensionHost observer at the correct tim… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: roll back some stuff Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_EXTENSION_HOST_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_HOST_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_HOST_H_ 6 #define EXTENSIONS_BROWSER_EXTENSION_HOST_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 ExtensionHost(const Extension* extension, 52 ExtensionHost(const Extension* extension,
53 content::SiteInstance* site_instance, 53 content::SiteInstance* site_instance,
54 const GURL& url, ViewType host_type); 54 const GURL& url, ViewType host_type);
55 ~ExtensionHost() override; 55 ~ExtensionHost() override;
56 56
57 const Extension* extension() const { return extension_; } 57 const Extension* extension() const { return extension_; }
58 const std::string& extension_id() const { return extension_id_; } 58 const std::string& extension_id() const { return extension_id_; }
59 content::WebContents* host_contents() const { return host_contents_.get(); } 59 content::WebContents* host_contents() const { return host_contents_.get(); }
60 content::RenderViewHost* render_view_host() const; 60 content::RenderViewHost* render_view_host() const;
61 content::RenderProcessHost* render_process_host() const; 61 content::RenderProcessHost* render_process_host() const;
62 bool did_stop_loading() const { return did_stop_loading_; } 62 bool has_loaded_once() const { return has_loaded_once_; }
63 bool document_element_available() const { 63 bool document_element_available() const {
64 return document_element_available_; 64 return document_element_available_;
65 } 65 }
66 66
67 content::BrowserContext* browser_context() { return browser_context_; } 67 content::BrowserContext* browser_context() { return browser_context_; }
68 68
69 ViewType extension_host_type() const { return extension_host_type_; } 69 ViewType extension_host_type() const { return extension_host_type_; }
70 const GURL& GetURL() const; 70 const GURL& GetURL() const;
71 71
72 // Returns true if the render view is initialized and didn't crash. 72 // Returns true if the render view is initialized and didn't crash.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 const GURL& security_origin, 124 const GURL& security_origin,
125 content::MediaStreamType type) override; 125 content::MediaStreamType type) override;
126 bool IsNeverVisible(content::WebContents* web_contents) override; 126 bool IsNeverVisible(content::WebContents* web_contents) override;
127 127
128 // ExtensionRegistryObserver: 128 // ExtensionRegistryObserver:
129 void OnExtensionUnloaded(content::BrowserContext* browser_context, 129 void OnExtensionUnloaded(content::BrowserContext* browser_context,
130 const Extension* extension, 130 const Extension* extension,
131 UnloadedExtensionInfo::Reason reason) override; 131 UnloadedExtensionInfo::Reason reason) override;
132 132
133 protected: 133 protected:
134 // Called after the extension page finishes loading but before the 134 // Called each time this ExtensionHost completes a load finishes loading,
135 // EXTENSION_HOST_DID_STOP_LOADING notification is sent. 135 // before any stop-loading notifications or observer methods are called.
136 virtual void OnDidStopLoading(); 136 virtual void OnDidStopLoading();
137 137
138 // Navigates to the initial page. 138 // Navigates to the initial page.
139 virtual void LoadInitialURL(); 139 virtual void LoadInitialURL();
140 140
141 // Returns true if we're hosting a background page. 141 // Returns true if we're hosting a background page.
142 virtual bool IsBackgroundPage() const; 142 virtual bool IsBackgroundPage() const;
143 143
144 private: 144 private:
145 // DeferredStartRenderHost: 145 // DeferredStartRenderHost:
146 void CreateRenderViewNow() override; 146 void CreateRenderViewNow() override;
147 void AddDeferredStartRenderHostObserver( 147 void AddDeferredStartRenderHostObserver(
148 DeferredStartRenderHostObserver* observer) override; 148 DeferredStartRenderHostObserver* observer) override;
149 void RemoveDeferredStartRenderHostObserver( 149 void RemoveDeferredStartRenderHostObserver(
150 DeferredStartRenderHostObserver* observer) override; 150 DeferredStartRenderHostObserver* observer) override;
151 151
152 // Message handlers. 152 // Message handlers.
153 void OnRequest(const ExtensionHostMsg_Request_Params& params); 153 void OnRequest(const ExtensionHostMsg_Request_Params& params);
154 void OnEventAck(int event_id); 154 void OnEventAck(int event_id);
155 void OnIncrementLazyKeepaliveCount(); 155 void OnIncrementLazyKeepaliveCount();
156 void OnDecrementLazyKeepaliveCount(); 156 void OnDecrementLazyKeepaliveCount();
157 157
158 // Records UMA for load events.
159 void RecordStopLoadingUMA();
160
158 // Delegate for functionality that cannot exist in the extensions module. 161 // Delegate for functionality that cannot exist in the extensions module.
159 scoped_ptr<ExtensionHostDelegate> delegate_; 162 scoped_ptr<ExtensionHostDelegate> delegate_;
160 163
161 // The extension that we're hosting in this view. 164 // The extension that we're hosting in this view.
162 const Extension* extension_; 165 const Extension* extension_;
163 166
164 // Id of extension that we're hosting in this view. 167 // Id of extension that we're hosting in this view.
165 const std::string extension_id_; 168 const std::string extension_id_;
166 169
167 // The browser context that this host is tied to. 170 // The browser context that this host is tied to.
168 content::BrowserContext* browser_context_; 171 content::BrowserContext* browser_context_;
169 172
170 // The host for our HTML content. 173 // The host for our HTML content.
171 scoped_ptr<content::WebContents> host_contents_; 174 scoped_ptr<content::WebContents> host_contents_;
172 175
173 // A weak pointer to the current or pending RenderViewHost. We don't access 176 // A weak pointer to the current or pending RenderViewHost. We don't access
174 // this through the host_contents because we want to deal with the pending 177 // this through the host_contents because we want to deal with the pending
175 // host, so we can send messages to it before it finishes loading. 178 // host, so we can send messages to it before it finishes loading.
176 content::RenderViewHost* render_view_host_; 179 content::RenderViewHost* render_view_host_;
177 180
178 // Whether the RenderWidget has reported that it has stopped loading. 181 // Whether the ExtensionHost has finished loading some content at least once.
179 bool did_stop_loading_; 182 // There may be subsequent loads - such as reloads and navigations - and this
183 // will not affect its value (it will remain true).
184 bool has_loaded_once_;
180 185
181 // True if the main frame has finished parsing. 186 // True if the main frame has finished parsing.
182 bool document_element_available_; 187 bool document_element_available_;
183 188
184 // The original URL of the page being hosted. 189 // The original URL of the page being hosted.
185 GURL initial_url_; 190 GURL initial_url_;
186 191
187 // Messages sent out to the renderer that have not been acknowledged yet. 192 // Messages sent out to the renderer that have not been acknowledged yet.
188 std::set<int> unacked_messages_; 193 std::set<int> unacked_messages_;
189 194
190 ExtensionFunctionDispatcher extension_function_dispatcher_; 195 ExtensionFunctionDispatcher extension_function_dispatcher_;
191 196
192 // The type of view being hosted. 197 // The type of view being hosted.
193 ViewType extension_host_type_; 198 ViewType extension_host_type_;
194 199
195 // Measures how long since the initial URL started loading. 200 // Measures how long since the initial URL started loading.
196 scoped_ptr<base::ElapsedTimer> load_start_; 201 scoped_ptr<base::ElapsedTimer> load_start_;
197 202
198 ObserverList<ExtensionHostObserver> observer_list_; 203 ObserverList<ExtensionHostObserver> observer_list_;
199 ObserverList<DeferredStartRenderHostObserver> 204 ObserverList<DeferredStartRenderHostObserver>
200 deferred_start_render_host_observer_list_; 205 deferred_start_render_host_observer_list_;
201 206
202 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); 207 DISALLOW_COPY_AND_ASSIGN(ExtensionHost);
203 }; 208 };
204 209
205 } // namespace extensions 210 } // namespace extensions
206 211
207 #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_ 212 #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_view_views.cc ('k') | extensions/browser/extension_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698