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

Unified Diff: third_party/mojo/src/mojo/public/cpp/bindings/binding.h

Issue 975973002: Update mojo sdk to rev f68e697e389943cd9bf9652397312280e96b127a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: shake fist at msvc Created 5 years, 10 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: third_party/mojo/src/mojo/public/cpp/bindings/binding.h
diff --git a/third_party/mojo/src/mojo/public/cpp/bindings/binding.h b/third_party/mojo/src/mojo/public/cpp/bindings/binding.h
index 77d015a67056e1ff3b518b3c6d124c7faffc14b8..db5e96d911336308ea05676cae5a93dec6da8f4e 100644
--- a/third_party/mojo/src/mojo/public/cpp/bindings/binding.h
+++ b/third_party/mojo/src/mojo/public/cpp/bindings/binding.h
@@ -101,8 +101,7 @@ class Binding : public ErrorHandler {
// implementation unbound.
~Binding() override {
if (internal_router_) {
- internal_router_->set_error_handler(nullptr);
- delete internal_router_;
+ DestroyRouter();
}
}
@@ -112,6 +111,7 @@ class Binding : public ErrorHandler {
void Bind(
ScopedMessagePipeHandle handle,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()) {
+ MOJO_DCHECK(!internal_router_);
internal::FilterChain filters;
filters.Append<internal::MessageHeaderValidator>();
filters.Append<typename Interface::RequestValidator_>();
@@ -153,17 +153,23 @@ class Binding : public ErrorHandler {
return internal_router_->WaitForIncomingMessage();
}
- // Closes the message pipe that was previously bound.
+ // Closes the message pipe that was previously bound. Put this object into a
+ // state where it can be rebound to a new pipe.
void Close() {
MOJO_DCHECK(internal_router_);
internal_router_->CloseMessagePipe();
+ DestroyRouter();
}
// Unbinds the underlying pipe from this binding and returns it so it can be
// used in another context, such as on another thread or with a different
- // implementation.
+ // implementation. Put this object into a state where it can be rebound to a
+ // new pipe.
InterfaceRequest<Interface> Unbind() {
- return MakeRequest<Interface>(internal_router_->PassMessagePipe());
+ InterfaceRequest<Interface> request =
+ MakeRequest<Interface>(internal_router_->PassMessagePipe());
+ DestroyRouter();
+ return request.Pass();
}
// Sets an error handler that will be called if a connection error occurs on
@@ -190,6 +196,12 @@ class Binding : public ErrorHandler {
internal::Router* internal_router() { return internal_router_; }
private:
+ void DestroyRouter() {
+ internal_router_->set_error_handler(nullptr);
+ delete internal_router_;
+ internal_router_ = nullptr;
+ }
+
internal::Router* internal_router_ = nullptr;
typename Interface::Stub_ stub_;
Interface* impl_;
« no previous file with comments | « third_party/mojo/src/mojo/public/cpp/bindings/BUILD.gn ('k') | third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698