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

Unified Diff: content/public/browser/web_contents_observer.h

Issue 257153003: We have a problem in the process on destroying WebContentsImpl because (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Rebased onto origin/lkgr Created 6 years, 8 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: content/public/browser/web_contents_observer.h
diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h
index 9fae539faf6e3a97c3198e6d95a3e703202a7982..59e02b414479dc70b1a60d7e3c3d37f9c0d9c1d8 100644
--- a/content/public/browser/web_contents_observer.h
+++ b/content/public/browser/web_contents_observer.h
@@ -292,10 +292,18 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener,
virtual void DidCloneToNewWebContents(WebContents* old_web_contents,
WebContents* new_web_contents) {}
- // Invoked when the WebContents is being destroyed. Gives subclasses a chance
- // to cleanup. At the time this is invoked |web_contents()| returns NULL.
- // It is safe to delete 'this' from here.
- virtual void WebContentsDestroyed(WebContents* web_contents) {}
+ // When WebContents is being destroyed it notifies its observers and this
+ // process is split in two phases (untrusted and trusted).
jam 2014/05/02 19:34:11 this trusted and untrusted terminology is a bit co
zverre 2014/05/05 16:40:25 Done.
+ // First WebContents loops through its observers and calls
+ // WebContentsDestroyed to let them run cleanup code. At the time this is
+ // invoked |web_contents()| is guaranteed to be non NULL for all
+ // WebContentsObservers so they can directly or indirectly call each other.
+ // It is safe to delete 'this' from here. When this loop has been finished
+ // trusted phase starts, WebContents loops its WebContentsObservers again
+ // and NULLs its |web_contents_| pointers. This is done by calling
+ // WebContentsDestroyed and this behavior can't be modified since it is
+ // private.
+ virtual void WebContentsDestroyed() {}
// Called when the user agent override for a WebContents has been changed.
virtual void UserAgentOverrideSet(const std::string& user_agent) {}
@@ -359,9 +367,9 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener,
private:
friend class WebContentsImpl;
- // Invoked from WebContentsImpl. Invokes WebContentsDestroyed and NULL out
- // |web_contents_|.
- void WebContentsImplDestroyed();
+ // Resets |web_contents_| pointer to NULL as a final step in the process
+ // of destroying the WebContents. See comments near WebContentsDestroyed.
+ void WebContentsDestroyedPrivate() { web_contents_ = NULL; }
jam 2014/05/02 19:34:11 nit: since it's inline and it's a simple method, i
zverre 2014/05/05 12:40:43 Jam, thank you for your comments. I don't really w
jam 2014/05/05 15:05:03 ok sure. i don't feel strongly about it (btw for t
zverre 2014/05/05 16:40:25 Done.
WebContentsImpl* web_contents_;

Powered by Google App Engine
This is Rietveld 408576698