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

Unified Diff: mojo/public/cpp/bindings/associated_binding.cc

Issue 2680243003: Reduce size of mojo AssociatedBinding template expansions (Closed)
Patch Set: forgot cc Created 3 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: mojo/public/cpp/bindings/associated_binding.cc
diff --git a/mojo/public/cpp/bindings/associated_binding.cc b/mojo/public/cpp/bindings/associated_binding.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6735a541cde86fbda155edf7381064b5400808ae
--- /dev/null
+++ b/mojo/public/cpp/bindings/associated_binding.cc
@@ -0,0 +1,65 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
yzshen1 2017/02/09 00:36:52 Please put this file in the lib/ directory.
scottmg 2017/02/09 01:15:08 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/public/cpp/bindings/associated_binding.h"
+
+namespace mojo {
+
+AssociatedBindingBase::AssociatedBindingBase() {}
+
+AssociatedBindingBase::~AssociatedBindingBase() {}
+
+void AssociatedBindingBase::AddFilter(std::unique_ptr<MessageReceiver> filter) {
+ DCHECK(endpoint_client_);
+ endpoint_client_->AddFilter(std::move(filter));
+}
+
+void AssociatedBindingBase::Close() {
+ endpoint_client_.reset();
+}
+
+void AssociatedBindingBase::CloseWithReason(uint32_t custom_reason,
+ const std::string& description) {
+ if (endpoint_client_)
+ endpoint_client_->CloseWithReason(custom_reason, description);
+ Close();
+}
+
+void AssociatedBindingBase::set_connection_error_handler(const base::Closure& error_handler) {
yzshen1 2017/02/09 00:36:52 Please run git cl format.
scottmg 2017/02/09 01:15:08 Oops, done.
+ DCHECK(is_bound());
+ endpoint_client_->set_connection_error_handler(error_handler);
+}
+
+void AssociatedBindingBase::set_connection_error_with_reason_handler(
+ const ConnectionErrorWithReasonCallback& error_handler) {
+ DCHECK(is_bound());
+ endpoint_client_->set_connection_error_with_reason_handler(error_handler);
+}
+
+void AssociatedBindingBase::FlushForTesting() {
+ endpoint_client_->control_message_proxy()->FlushForTesting();
+}
+
+void AssociatedBindingBase::BindImpl(
+ ScopedInterfaceEndpointHandle handle,
+ MessageReceiverWithResponderStatus* receiver,
+ std::unique_ptr<MessageReceiver> payload_validator,
+ bool expect_sync_requests,
+ scoped_refptr<base::SingleThreadTaskRunner> runner,
+ uint32_t interface_version) {
+ DCHECK(handle.is_local())
+ << "The AssociatedInterfaceRequest is supposed to be used at the "
+ << "other side of the message pipe.";
+
+ if (!handle.is_valid() || !handle.is_local()) {
+ endpoint_client_.reset();
+ return;
+ }
+
+ endpoint_client_.reset(new InterfaceEndpointClient(
+ std::move(handle), receiver, std::move(payload_validator),
+ expect_sync_requests, std::move(runner), interface_version));
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698