Index: mojo/public/cpp/bindings/strong_associated_binding.h |
diff --git a/mojo/public/cpp/bindings/strong_binding.h b/mojo/public/cpp/bindings/strong_associated_binding.h |
similarity index 51% |
copy from mojo/public/cpp/bindings/strong_binding.h |
copy to mojo/public/cpp/bindings/strong_associated_binding.h |
index 99d10956c6f040e2835ff9f705f713f38486a641..4d77a35ee8e4b0d485e1e4ce85353e4fe2c37739 100644 |
--- a/mojo/public/cpp/bindings/strong_binding.h |
+++ b/mojo/public/cpp/bindings/strong_associated_binding.h |
@@ -1,9 +1,9 @@ |
-// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Copyright 2016 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 MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
-#define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
+#ifndef MOJO_PUBLIC_CPP_BINDINGS_STRONG_ASSOCIATED_BINDING_H_ |
+#define MOJO_PUBLIC_CPP_BINDINGS_STRONG_ASSOCIATED_BINDING_H_ |
#include <memory> |
#include <string> |
@@ -14,50 +14,47 @@ |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/memory/weak_ptr.h" |
-#include "mojo/public/cpp/bindings/binding.h" |
+#include "mojo/public/cpp/bindings/associated_binding.h" |
+#include "mojo/public/cpp/bindings/associated_interface_request.h" |
#include "mojo/public/cpp/bindings/connection_error_callback.h" |
-#include "mojo/public/cpp/bindings/filter_chain.h" |
-#include "mojo/public/cpp/bindings/interface_ptr.h" |
-#include "mojo/public/cpp/bindings/interface_request.h" |
-#include "mojo/public/cpp/bindings/lib/router.h" |
-#include "mojo/public/cpp/bindings/message_header_validator.h" |
#include "mojo/public/cpp/system/core.h" |
namespace mojo { |
template <typename Interface> |
-class StrongBinding; |
+class StrongAssociatedBinding; |
template <typename Interface> |
-using StrongBindingPtr = base::WeakPtr<StrongBinding<Interface>>; |
+using StrongAssociatedBindingPtr = |
+ base::WeakPtr<StrongAssociatedBinding<Interface>>; |
-// This connects an interface implementation strongly to a pipe. When a |
-// connection error is detected the implementation is deleted. |
+// This connects an interface implementation strongly to an associated pipe. |
+// When a connection error is detected the implementation is deleted. |
// |
-// To use, call StrongBinding<T>::Create() (see below) or the helper |
-// MakeStrongBinding function: |
+// To use, call StrongAssociatedBinding<T>::Create() (see below) or the helper |
+// MakeStrongAssociatedBinding function: |
// |
-// mojo::MakeStrongBinding(base::MakeUnique<FooImpl>(), |
-// std::move(foo_request)); |
+// mojo::MakeStrongAssociatedBinding(base::MakeUnique<FooImpl>(), |
+// std::move(foo_request)); |
// |
template <typename Interface> |
-class StrongBinding { |
+class StrongAssociatedBinding { |
public: |
- // Create a new StrongBinding instance. The instance owns itself, cleaning up |
- // only in the event of a pipe connection error. Returns a WeakPtr to the new |
- // StrongBinding instance. |
- static StrongBindingPtr<Interface> Create( |
+ // Create a new StrongAssociatedBinding instance. The instance owns itself, |
+ // cleaning up only in the event of a pipe connection error. Returns a WeakPtr |
+ // to the new StrongAssociatedBinding instance. |
+ static StrongAssociatedBindingPtr<Interface> Create( |
std::unique_ptr<Interface> impl, |
- InterfaceRequest<Interface> request) { |
- StrongBinding* binding = |
- new StrongBinding(std::move(impl), std::move(request)); |
+ AssociatedInterfaceRequest<Interface> request) { |
+ StrongAssociatedBinding* binding = |
+ new StrongAssociatedBinding(std::move(impl), std::move(request)); |
return binding->weak_factory_.GetWeakPtr(); |
} |
// Note: The error handler must not delete the interface implementation. |
// |
- // This method may only be called after this StrongBinding has been bound to a |
- // message pipe. |
+ // This method may only be called after this StrongAssociatedBinding has been |
+ // bound to a message pipe. |
void set_connection_error_handler(const base::Closure& error_handler) { |
DCHECK(binding_.is_bound()); |
connection_error_handler_ = error_handler; |
@@ -76,9 +73,6 @@ class StrongBinding { |
Interface* impl() { return impl_.get(); } |
- // Exposed for testing, should not generally be used. |
- internal::Router* internal_router() { return binding_.internal_router(); } |
- |
// Sends a message on the underlying message pipe and runs the current |
// message loop until its response is received. This can be used in tests to |
// verify that no message was sent on a message pipe in response to some |
@@ -86,16 +80,16 @@ class StrongBinding { |
void FlushForTesting() { binding_.FlushForTesting(); } |
private: |
- StrongBinding(std::unique_ptr<Interface> impl, |
- InterfaceRequest<Interface> request) |
+ StrongAssociatedBinding(std::unique_ptr<Interface> impl, |
+ AssociatedInterfaceRequest<Interface> request) |
: impl_(std::move(impl)), |
binding_(impl_.get(), std::move(request)), |
weak_factory_(this) { |
- binding_.set_connection_error_with_reason_handler( |
- base::Bind(&StrongBinding::OnConnectionError, base::Unretained(this))); |
+ binding_.set_connection_error_with_reason_handler(base::Bind( |
+ &StrongAssociatedBinding::OnConnectionError, base::Unretained(this))); |
} |
- ~StrongBinding() {} |
+ ~StrongAssociatedBinding() {} |
void OnConnectionError(uint32_t custom_reason, |
const std::string& description) { |
@@ -109,19 +103,20 @@ class StrongBinding { |
std::unique_ptr<Interface> impl_; |
base::Closure connection_error_handler_; |
ConnectionErrorWithReasonCallback connection_error_with_reason_handler_; |
- Binding<Interface> binding_; |
- base::WeakPtrFactory<StrongBinding> weak_factory_; |
+ AssociatedBinding<Interface> binding_; |
+ base::WeakPtrFactory<StrongAssociatedBinding> weak_factory_; |
- DISALLOW_COPY_AND_ASSIGN(StrongBinding); |
+ DISALLOW_COPY_AND_ASSIGN(StrongAssociatedBinding); |
}; |
template <typename Interface, typename Impl> |
-StrongBindingPtr<Interface> MakeStrongBinding( |
+StrongAssociatedBindingPtr<Interface> MakeStrongAssociatedBinding( |
std::unique_ptr<Impl> impl, |
- InterfaceRequest<Interface> request) { |
- return StrongBinding<Interface>::Create(std::move(impl), std::move(request)); |
+ AssociatedInterfaceRequest<Interface> request) { |
+ return StrongAssociatedBinding<Interface>::Create(std::move(impl), |
+ std::move(request)); |
} |
} // namespace mojo |
-#endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ |
+#endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_ASSOCIATED_BINDING_H_ |