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

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: aha 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. Called both from DidStopLoading and from the
159 // destructor.
160 void RecordStopLoadingUMA();
161
158 // Delegate for functionality that cannot exist in the extensions module. 162 // Delegate for functionality that cannot exist in the extensions module.
159 scoped_ptr<ExtensionHostDelegate> delegate_; 163 scoped_ptr<ExtensionHostDelegate> delegate_;
160 164
161 // The extension that we're hosting in this view. 165 // The extension that we're hosting in this view.
162 const Extension* extension_; 166 const Extension* extension_;
163 167
164 // Id of extension that we're hosting in this view. 168 // Id of extension that we're hosting in this view.
165 const std::string extension_id_; 169 const std::string extension_id_;
166 170
167 // The browser context that this host is tied to. 171 // The browser context that this host is tied to.
168 content::BrowserContext* browser_context_; 172 content::BrowserContext* browser_context_;
169 173
170 // The host for our HTML content. 174 // The host for our HTML content.
171 scoped_ptr<content::WebContents> host_contents_; 175 scoped_ptr<content::WebContents> host_contents_;
172 176
173 // A weak pointer to the current or pending RenderViewHost. We don't access 177 // 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 178 // 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. 179 // host, so we can send messages to it before it finishes loading.
176 content::RenderViewHost* render_view_host_; 180 content::RenderViewHost* render_view_host_;
177 181
178 // Whether the RenderWidget has reported that it has stopped loading. 182 // Whether the ExtensionHost is currently in the process of loading, i.e. if
179 bool did_stop_loading_; 183 // the DidStartLoading event has fired but the DidStopLoading event hasn't.
184 bool is_loading_;
185
186 // Whether the ExtensionHost has finished loading some content at least once.
187 // There may be subsequent loads - such as reloads and navigations - and this
188 // will not affect its value (it will remain true).
189 bool has_loaded_once_;
180 190
181 // True if the main frame has finished parsing. 191 // True if the main frame has finished parsing.
182 bool document_element_available_; 192 bool document_element_available_;
183 193
184 // The original URL of the page being hosted. 194 // The original URL of the page being hosted.
185 GURL initial_url_; 195 GURL initial_url_;
186 196
187 // Messages sent out to the renderer that have not been acknowledged yet. 197 // Messages sent out to the renderer that have not been acknowledged yet.
188 std::set<int> unacked_messages_; 198 std::set<int> unacked_messages_;
189 199
190 ExtensionFunctionDispatcher extension_function_dispatcher_; 200 ExtensionFunctionDispatcher extension_function_dispatcher_;
191 201
192 // The type of view being hosted. 202 // The type of view being hosted.
193 ViewType extension_host_type_; 203 ViewType extension_host_type_;
194 204
195 // Measures how long since the initial URL started loading. 205 // Measures how long since the initial URL started loading.
196 scoped_ptr<base::ElapsedTimer> load_start_; 206 scoped_ptr<base::ElapsedTimer> load_start_;
197 207
198 ObserverList<ExtensionHostObserver> observer_list_; 208 ObserverList<ExtensionHostObserver> observer_list_;
199 ObserverList<DeferredStartRenderHostObserver> 209 ObserverList<DeferredStartRenderHostObserver>
200 deferred_start_render_host_observer_list_; 210 deferred_start_render_host_observer_list_;
201 211
202 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); 212 DISALLOW_COPY_AND_ASSIGN(ExtensionHost);
203 }; 213 };
204 214
205 } // namespace extensions 215 } // namespace extensions
206 216
207 #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_ 217 #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698