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

Unified 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: Addressed comment by kalman@. 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 side-by-side diff with in-line comments
Download patch
Index: components/guest_view/browser/guest_view_manager.h
diff --git a/components/guest_view/browser/guest_view_manager.h b/components/guest_view/browser/guest_view_manager.h
index 5364edefcb920e6047d70c503f42e75ed56552c0..87b1831481bcc4ef3c19803355605ab8bf168d35 100644
--- a/components/guest_view/browser/guest_view_manager.h
+++ b/components/guest_view/browser/guest_view_manager.h
@@ -6,12 +6,14 @@
#define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_H_
#include <map>
+#include <set>
#include <vector>
#include "base/bind.h"
#include "base/gtest_prod_util.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/browser_plugin_guest_manager.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
@@ -132,6 +134,8 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
friend class GuestViewEvent;
friend class GuestViewMessageFilter;
+ class EmbedderRenderProcessHostObserver;
+
// These methods are virtual so that they can be overriden in tests.
virtual void AddGuest(int guest_instance_id,
@@ -139,8 +143,8 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
virtual void RemoveGuest(int guest_instance_id);
// This method is called when the embedder process with ID
- // |embedder_process_id| is about to be destroyed.
- virtual void EmbedderWillBeDestroyed(int embedder_process_id);
+ // |embedder_process_id| has been destroyed.
+ virtual void EmbedderProcessDestroyed(int embedder_process_id);
// Called when a GuestView has been created in JavaScript.
virtual void ViewCreated(int embedder_process_id,
@@ -151,6 +155,15 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
virtual void ViewGarbageCollected(int embedder_process_id,
int view_instance_id);
+ // Calls all destruction callbacks registered for the GuestView identified by
+ // |embedder_process_id| and |view_instance_id|.
+ void CallViewDestructionCallbacks(int embedder_process_id,
+ int view_instance_id);
+
+ // Calls all destruction callbacks registered for GuestViews in the embedder
+ // with ID |embedder_process_id|.
+ void CallViewDestructionCallbacks(int embedder_process_id);
+
// Creates a guest of the provided |view_type|.
GuestViewBase* CreateGuestInternal(content::WebContents* owner_web_contents,
const std::string& view_type);
@@ -215,7 +228,8 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
using GuestViewCreateFunction =
base::Callback<GuestViewBase*(content::WebContents*)>;
- using GuestViewCleanUpFunction = base::Callback<void(int, int)>;
+ using GuestViewCleanUpFunction =
+ base::Callback<void(content::BrowserContext*, int, int)>;
struct GuestViewData {
GuestViewData(const GuestViewCreateFunction& create_function,
const GuestViewCleanUpFunction& cleanup_function);
@@ -241,6 +255,9 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
scoped_ptr<GuestViewManagerDelegate> delegate_;
+ // This tracks which GuestView embedders are currently being observed.
+ std::set<int> embedders_observed_;
+
// |view_destruction_callback_map_| maps from embedder process ID to view ID
// to a vector of callback functions to be called when that view is destroyed.
using Callbacks = std::vector<base::Closure> ;
@@ -248,6 +265,10 @@ class GuestViewManager : public content::BrowserPluginGuestManager,
using CallbacksForEachEmbedderID = std::map<int, CallbacksForEachViewID> ;
CallbacksForEachEmbedderID view_destruction_callback_map_;
+ // This is used to ensure that an EmbedderRenderProcessHostObserver will not
+ // call into this GuestViewManager after it has been destroyed.
+ base::WeakPtrFactory<GuestViewManager> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(GuestViewManager);
};
« no previous file with comments | « components/guest_view/browser/guest_view_base.cc ('k') | components/guest_view/browser/guest_view_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698