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

Unified Diff: chrome/browser/ui/cocoa/has_weak_browser_pointer.h

Issue 1221173003: [Mac] Inform reference counted objects that hold a weak Browser* when the Browser is being destroye… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. 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: chrome/browser/ui/cocoa/has_weak_browser_pointer.h
diff --git a/chrome/browser/ui/cocoa/has_weak_browser_pointer.h b/chrome/browser/ui/cocoa/has_weak_browser_pointer.h
new file mode 100644
index 0000000000000000000000000000000000000000..39fd3123318c196de67f09a120bf3014ea059f20
--- /dev/null
+++ b/chrome/browser/ui/cocoa/has_weak_browser_pointer.h
@@ -0,0 +1,22 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_COCOA_HAS_WEAK_BROWSER_POINTER_H_
+#define CHROME_BROWSER_UI_COCOA_HAS_WEAK_BROWSER_POINTER_H_
+
+// This allows reference counted objects holding a Browser* to be
+// notified that the Browser will be destroyed so they can invalidate their
+// Browser*, perform any necessary cleanup, and pass the notification onto any
+// objects they retain that also implement this protocol. This helps to prevent
+// use-after-free of Browser*, or anything else tied to the Browser's lifetime,
+// by objects that may be retained beyond the lifetime of their associated
+// Browser (e.g. NSViewControllers).
+@protocol HasWeakBrowserPointer
+@required
+// This is usually called by BrowserWindowController but can be called by any
+// object that's certain of Browser's destruction.
+- (void)browserWillBeDestroyed;
+@end
+
+#endif // CHROME_BROWSER_UI_COCOA_HAS_WEAK_BROWSER_POINTER_H_

Powered by Google App Engine
This is Rietveld 408576698