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

Unified Diff: mojo/bindings/js/handle.h

Issue 534953002: Mojo: Cancel WaitingCallbacks when their HandleWrappers are closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ObserverList Created 6 years, 3 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
« no previous file with comments | « no previous file | mojo/bindings/js/handle.cc » ('j') | mojo/bindings/js/handle.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/bindings/js/handle.h
diff --git a/mojo/bindings/js/handle.h b/mojo/bindings/js/handle.h
index 35202b07ea674240bdc4b81c6702f718f8b9d696..8c94c95ac28c871de2de6ccf9a1f0e7c015d4908 100644
--- a/mojo/bindings/js/handle.h
+++ b/mojo/bindings/js/handle.h
@@ -5,6 +5,7 @@
#ifndef MOJO_BINDINGS_JS_HANDLE_H_
#define MOJO_BINDINGS_JS_HANDLE_H_
+#include "base/observer_list.h"
#include "gin/converter.h"
#include "gin/handle.h"
#include "gin/wrappable.h"
@@ -16,6 +17,11 @@ namespace gin {
// is Closed when its JS object is garbage collected.
class HandleWrapper : public gin::Wrappable<HandleWrapper> {
public:
+ class CloseObserver {
sky 2014/09/03 15:47:04 Move this into its own file and make the destructo
Sam McNally 2014/09/08 04:31:52 Done.
+ public:
+ virtual ~CloseObserver() {}
+ virtual void OnHandleClosed() = 0;
sky 2014/09/03 15:47:04 Isn't this sent before the close? Wouldn't OnWillC
Sam McNally 2014/09/08 04:31:52 Done.
+ };
static gin::WrapperInfo kWrapperInfo;
static gin::Handle<HandleWrapper> Create(v8::Isolate* isolate,
@@ -25,12 +31,17 @@ class HandleWrapper : public gin::Wrappable<HandleWrapper> {
mojo::Handle get() const { return handle_.get(); }
mojo::Handle release() { return handle_.release(); }
- void Close() { handle_.reset(); }
+ void Close();
+
+ void AddCloseObserver(CloseObserver* observer);
+ void RemoveCloseObserver(CloseObserver* observer);
protected:
HandleWrapper(MojoHandle handle);
virtual ~HandleWrapper();
+ void NotifyCloseObservers();
mojo::ScopedHandle handle_;
sky 2014/09/03 15:47:04 nit: newline between 42/43.
Sam McNally 2014/09/08 04:31:52 Done.
+ ObserverList<CloseObserver> close_observers_;
};
// Note: It's important to use this converter rather than the one for
« no previous file with comments | « no previous file | mojo/bindings/js/handle.cc » ('j') | mojo/bindings/js/handle.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698