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

Side by Side Diff: components/guest_view/browser/guest_view_manager.h

Issue 1232603002: This patch improves the way that GuestViewManager tracks the destruction of GuestView embedders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_H_ 5 #ifndef COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_H_
6 #define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_H_ 6 #define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bool ForEachGuest(content::WebContents* owner_web_contents, 125 bool ForEachGuest(content::WebContents* owner_web_contents,
126 const GuestCallback& callback) override; 126 const GuestCallback& callback) override;
127 content::WebContents* GetFullPageGuest( 127 content::WebContents* GetFullPageGuest(
128 content::WebContents* embedder_web_contents) override; 128 content::WebContents* embedder_web_contents) override;
129 129
130 protected: 130 protected:
131 friend class GuestViewBase; 131 friend class GuestViewBase;
132 friend class GuestViewEvent; 132 friend class GuestViewEvent;
133 friend class GuestViewMessageFilter; 133 friend class GuestViewMessageFilter;
134 134
135 class EmbedderRenderProcessHostObserver;
136
135 // These methods are virtual so that they can be overriden in tests. 137 // These methods are virtual so that they can be overriden in tests.
136 138
137 virtual void AddGuest(int guest_instance_id, 139 virtual void AddGuest(int guest_instance_id,
138 content::WebContents* guest_web_contents); 140 content::WebContents* guest_web_contents);
139 virtual void RemoveGuest(int guest_instance_id); 141 virtual void RemoveGuest(int guest_instance_id);
140 142
141 // This method is called when the embedder process with ID 143 // This method is called when the embedder process with ID
142 // |embedder_process_id| is about to be destroyed. 144 // |embedder_process_id| has been destroyed.
143 virtual void EmbedderWillBeDestroyed(int embedder_process_id); 145 virtual void EmbedderProcessDestroyed(int embedder_process_id);
144 146
145 // Called when a GuestView has been created in JavaScript. 147 // Called when a GuestView has been created in JavaScript.
146 virtual void ViewCreated(int embedder_process_id, 148 virtual void ViewCreated(int embedder_process_id,
147 int view_instance_id, 149 int view_instance_id,
148 const std::string& view_type); 150 const std::string& view_type);
149 151
150 // Called when a GuestView has been garbage collected in JavaScript. 152 // Called when a GuestView has been garbage collected in JavaScript.
151 virtual void ViewGarbageCollected(int embedder_process_id, 153 virtual void ViewGarbageCollected(int embedder_process_id,
152 int view_instance_id); 154 int view_instance_id);
153 155
156 // Calls all destruction callbacks registered for the GuestView identified by
157 // |embedder_process_id| and |view_instance_id|.
158 void CallViewDestructionCallbacks(int embedder_process_id,
159 int view_instance_id);
160
161 // Calls all destruction callbacks registered for GuestViews in the embedder
162 // with ID |embedder_process_id|.
163 void CallViewDestructionCallbacks(int embedder_process_id);
164
154 // Creates a guest of the provided |view_type|. 165 // Creates a guest of the provided |view_type|.
155 GuestViewBase* CreateGuestInternal(content::WebContents* owner_web_contents, 166 GuestViewBase* CreateGuestInternal(content::WebContents* owner_web_contents,
156 const std::string& view_type); 167 const std::string& view_type);
157 168
158 // Adds GuestView types to the GuestView registry. 169 // Adds GuestView types to the GuestView registry.
159 void RegisterGuestViewTypes(); 170 void RegisterGuestViewTypes();
160 171
161 // Indicates whether the provided |guest| can be used in the context it has 172 // Indicates whether the provided |guest| can be used in the context it has
162 // been created. 173 // been created.
163 bool IsGuestAvailableToContext(GuestViewBase* guest); 174 bool IsGuestAvailableToContext(GuestViewBase* guest);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 219
209 using GuestInstanceIDMap = std::map<ElementInstanceKey, int>; 220 using GuestInstanceIDMap = std::map<ElementInstanceKey, int>;
210 GuestInstanceIDMap instance_id_map_; 221 GuestInstanceIDMap instance_id_map_;
211 222
212 // The reverse map of GuestInstanceIDMap. 223 // The reverse map of GuestInstanceIDMap.
213 using GuestInstanceIDReverseMap = std::map<int, ElementInstanceKey>; 224 using GuestInstanceIDReverseMap = std::map<int, ElementInstanceKey>;
214 GuestInstanceIDReverseMap reverse_instance_id_map_; 225 GuestInstanceIDReverseMap reverse_instance_id_map_;
215 226
216 using GuestViewCreateFunction = 227 using GuestViewCreateFunction =
217 base::Callback<GuestViewBase*(content::WebContents*)>; 228 base::Callback<GuestViewBase*(content::WebContents*)>;
218 using GuestViewCleanUpFunction = base::Callback<void(int, int)>; 229 using GuestViewCleanUpFunction =
230 base::Callback<void(content::BrowserContext*, int, int)>;
219 struct GuestViewData { 231 struct GuestViewData {
220 GuestViewData(const GuestViewCreateFunction& create_function, 232 GuestViewData(const GuestViewCreateFunction& create_function,
221 const GuestViewCleanUpFunction& cleanup_function); 233 const GuestViewCleanUpFunction& cleanup_function);
222 ~GuestViewData(); 234 ~GuestViewData();
223 const GuestViewCreateFunction create_function; 235 const GuestViewCreateFunction create_function;
224 const GuestViewCleanUpFunction cleanup_function; 236 const GuestViewCleanUpFunction cleanup_function;
225 }; 237 };
226 using GuestViewMethodMap = std::map<std::string, GuestViewData>; 238 using GuestViewMethodMap = std::map<std::string, GuestViewData>;
227 GuestViewMethodMap guest_view_registry_; 239 GuestViewMethodMap guest_view_registry_;
228 240
(...skipping 12 matching lines...) Expand all
241 253
242 scoped_ptr<GuestViewManagerDelegate> delegate_; 254 scoped_ptr<GuestViewManagerDelegate> delegate_;
243 255
244 // |view_destruction_callback_map_| maps from embedder process ID to view ID 256 // |view_destruction_callback_map_| maps from embedder process ID to view ID
245 // to a vector of callback functions to be called when that view is destroyed. 257 // to a vector of callback functions to be called when that view is destroyed.
246 using Callbacks = std::vector<base::Closure> ; 258 using Callbacks = std::vector<base::Closure> ;
247 using CallbacksForEachViewID = std::map<int, Callbacks> ; 259 using CallbacksForEachViewID = std::map<int, Callbacks> ;
248 using CallbacksForEachEmbedderID = std::map<int, CallbacksForEachViewID> ; 260 using CallbacksForEachEmbedderID = std::map<int, CallbacksForEachViewID> ;
249 CallbacksForEachEmbedderID view_destruction_callback_map_; 261 CallbacksForEachEmbedderID view_destruction_callback_map_;
250 262
263 ScopedVector<EmbedderRenderProcessHostObserver>
264 embedder_render_process_host_observers_;
265
251 DISALLOW_COPY_AND_ASSIGN(GuestViewManager); 266 DISALLOW_COPY_AND_ASSIGN(GuestViewManager);
252 }; 267 };
253 268
254 } // namespace guest_view 269 } // namespace guest_view
255 270
256 #endif // COMPONETS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_H_ 271 #endif // COMPONETS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698