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

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

Issue 823703004: Tracking push events for lucid sleep (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Kill renderer if it sends a bad message id Created 5 years, 10 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 <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h"
13 #include "base/timer/elapsed_timer.h" 15 #include "base/timer/elapsed_timer.h"
14 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_contents_delegate.h" 18 #include "content/public/browser/web_contents_delegate.h"
17 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
18 #include "extensions/browser/extension_function_dispatcher.h" 20 #include "extensions/browser/extension_function_dispatcher.h"
19 #include "extensions/common/stack_frame.h" 21 #include "extensions/common/stack_frame.h"
20 #include "extensions/common/view_type.h" 22 #include "extensions/common/view_type.h"
21 23
22 class PrefsTabHelper; 24 class PrefsTabHelper;
23 25
24 namespace content { 26 namespace content {
25 class BrowserContext; 27 class BrowserContext;
26 class RenderProcessHost; 28 class RenderProcessHost;
27 class RenderWidgetHostView; 29 class RenderWidgetHostView;
28 class SiteInstance; 30 class SiteInstance;
29 } 31 }
30 32
31 namespace extensions { 33 namespace extensions {
32 class Extension; 34 class Extension;
33 class ExtensionHostDelegate; 35 class ExtensionHostDelegate;
36 class ExtensionHostObserver;
34 class WindowController; 37 class WindowController;
35 38
36 // This class is the browser component of an extension component's RenderView. 39 // This class is the browser component of an extension component's RenderView.
37 // It handles setting up the renderer process, if needed, with special 40 // It handles setting up the renderer process, if needed, with special
38 // privileges available to extensions. It may have a view to be shown in the 41 // privileges available to extensions. It may have a view to be shown in the
39 // browser UI, or it may be hidden. 42 // browser UI, or it may be hidden.
40 // 43 //
41 // If you are adding code that only affects visible extension views (and not 44 // If you are adding code that only affects visible extension views (and not
42 // invisible background pages) you should add it to ExtensionViewHost. 45 // invisible background pages) you should add it to ExtensionViewHost.
43 class ExtensionHost : public content::WebContentsDelegate, 46 class ExtensionHost : public content::WebContentsDelegate,
(...skipping 24 matching lines...) Expand all
68 const GURL& GetURL() const; 71 const GURL& GetURL() const;
69 72
70 // Returns true if the render view is initialized and didn't crash. 73 // Returns true if the render view is initialized and didn't crash.
71 bool IsRenderViewLive() const; 74 bool IsRenderViewLive() const;
72 75
73 // Prepares to initializes our RenderViewHost by creating its RenderView and 76 // Prepares to initializes our RenderViewHost by creating its RenderView and
74 // navigating to this host's url. Uses host_view for the RenderViewHost's view 77 // navigating to this host's url. Uses host_view for the RenderViewHost's view
75 // (can be NULL). This happens delayed to avoid locking the UI. 78 // (can be NULL). This happens delayed to avoid locking the UI.
76 void CreateRenderViewSoon(); 79 void CreateRenderViewSoon();
77 80
81 // Typical observer interface.
82 void AddObserver(ExtensionHostObserver* observer);
83 void RemoveObserver(ExtensionHostObserver* observer);
84
85 // Called when an IPC message is dispatched to the RenderView associated with
86 // this ExtensionHost.
87 void OnMessageDispatched(const std::string& event_name, int message_id);
88
89 // Called by the ProcessManager when a network request is started by the
90 // extension corresponding to this ExtensionHost.
91 void OnNetworkRequestStarted(uint64 request_id);
92
93 // Called by the ProcessManager when a previously started network request is
94 // finished.
95 void OnNetworkRequestDone(uint64 request_id);
96
78 // content::WebContentsObserver 97 // content::WebContentsObserver
79 bool OnMessageReceived(const IPC::Message& message) override; 98 bool OnMessageReceived(const IPC::Message& message) override;
80 void RenderViewCreated(content::RenderViewHost* render_view_host) override; 99 void RenderViewCreated(content::RenderViewHost* render_view_host) override;
81 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; 100 void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
82 void RenderViewReady() override; 101 void RenderViewReady() override;
83 void RenderProcessGone(base::TerminationStatus status) override; 102 void RenderProcessGone(base::TerminationStatus status) override;
84 void DocumentAvailableInMainFrame() override; 103 void DocumentAvailableInMainFrame() override;
85 void DidStopLoading(content::RenderViewHost* render_view_host) override; 104 void DidStopLoading(content::RenderViewHost* render_view_host) override;
86 105
87 // content::WebContentsDelegate 106 // content::WebContentsDelegate
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void Close(); 147 void Close();
129 148
130 private: 149 private:
131 friend class ProcessCreationQueue; 150 friend class ProcessCreationQueue;
132 151
133 // Actually create the RenderView for this host. See CreateRenderViewSoon. 152 // Actually create the RenderView for this host. See CreateRenderViewSoon.
134 void CreateRenderViewNow(); 153 void CreateRenderViewNow();
135 154
136 // Message handlers. 155 // Message handlers.
137 void OnRequest(const ExtensionHostMsg_Request_Params& params); 156 void OnRequest(const ExtensionHostMsg_Request_Params& params);
138 void OnEventAck(); 157 void OnEventAck(int message_id);
139 void OnIncrementLazyKeepaliveCount(); 158 void OnIncrementLazyKeepaliveCount();
140 void OnDecrementLazyKeepaliveCount(); 159 void OnDecrementLazyKeepaliveCount();
141 160
142 // Delegate for functionality that cannot exist in the extensions module. 161 // Delegate for functionality that cannot exist in the extensions module.
143 scoped_ptr<ExtensionHostDelegate> delegate_; 162 scoped_ptr<ExtensionHostDelegate> delegate_;
144 163
145 // The extension that we're hosting in this view. 164 // The extension that we're hosting in this view.
146 const Extension* extension_; 165 const Extension* extension_;
147 166
148 // Id of extension that we're hosting in this view. 167 // Id of extension that we're hosting in this view.
(...skipping 12 matching lines...) Expand all
161 180
162 // Whether the RenderWidget has reported that it has stopped loading. 181 // Whether the RenderWidget has reported that it has stopped loading.
163 bool did_stop_loading_; 182 bool did_stop_loading_;
164 183
165 // True if the main frame has finished parsing. 184 // True if the main frame has finished parsing.
166 bool document_element_available_; 185 bool document_element_available_;
167 186
168 // The original URL of the page being hosted. 187 // The original URL of the page being hosted.
169 GURL initial_url_; 188 GURL initial_url_;
170 189
190 // Messages sent out to the renderer that have not been acknowledged yet.
191 std::set<int> unacked_messages_;
192
171 content::NotificationRegistrar registrar_; 193 content::NotificationRegistrar registrar_;
172 194
173 ExtensionFunctionDispatcher extension_function_dispatcher_; 195 ExtensionFunctionDispatcher extension_function_dispatcher_;
174 196
175 // The type of view being hosted. 197 // The type of view being hosted.
176 ViewType extension_host_type_; 198 ViewType extension_host_type_;
177 199
178 // Used to measure how long it's been since the host was created. 200 // Used to measure how long it's been since the host was created.
179 base::ElapsedTimer since_created_; 201 base::ElapsedTimer since_created_;
180 202
203 ObserverList<ExtensionHostObserver> observer_list_;
204
181 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); 205 DISALLOW_COPY_AND_ASSIGN(ExtensionHost);
182 }; 206 };
183 207
184 } // namespace extensions 208 } // namespace extensions
185 209
186 #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_ 210 #endif // EXTENSIONS_BROWSER_EXTENSION_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698