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

Unified Diff: mojo/public/cpp/bindings/lib/interface_ptr_state.cc

Issue 2205193002: WIP: Reduce code size of InterfacePtrState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@before-sharing
Patch Set: Add missing, new .cc file Created 4 years, 4 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 | « mojo/public/cpp/bindings/lib/interface_ptr_state.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/lib/interface_ptr_state.cc
diff --git a/mojo/public/cpp/bindings/lib/interface_ptr_state.cc b/mojo/public/cpp/bindings/lib/interface_ptr_state.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8287736881360fb09fc5d3d060b9c92ca80d8a96
--- /dev/null
+++ b/mojo/public/cpp/bindings/lib/interface_ptr_state.cc
@@ -0,0 +1,82 @@
+// 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.
+
+#include "mojo/public/cpp/bindings/lib/interface_ptr_state.h"
+
+namespace mojo {
+namespace internal {
+
+SimpleInterfacePtrState::SimpleInterfacePtrState()
+ : router_(nullptr), version_(0u) {}
+
+SimpleInterfacePtrState::~SimpleInterfacePtrState() {
+ delete router_;
+}
+
+void SimpleInterfacePtrState::QueryVersion(
+ const base::Callback<void(uint32_t)>& callback) {
+ ConfigureProxyIfNecessary();
+
+ // It is safe to capture |this| because the callback won't be run after this
+ // object goes away.
+ proxy()->QueryVersion(base::Bind(&SimpleInterfacePtrState::OnQueryVersion,
+ base::Unretained(this), callback));
+}
+
+void SimpleInterfacePtrState::RequireVersion(uint32_t version) {
+ ConfigureProxyIfNecessary();
+
+ if (version <= version_)
+ return;
+
+ version_ = version;
+ proxy()->RequireVersion(version);
+}
+
+bool SimpleInterfacePtrState::HasAssociatedInterfaces() const {
+ return false;
+}
+
+void SimpleInterfacePtrState::EnableTestingMode() {
+ ConfigureProxyIfNecessary();
+ router_->EnableTestingMode();
+}
+
+void SimpleInterfacePtrState::BindInternal(
+ InterfacePtrInfoBase* info,
+ scoped_refptr<base::SingleThreadTaskRunner> runner) {
+ DCHECK(!router_);
+ DCHECK(!handle_.is_valid());
+ DCHECK_EQ(0u, version_);
+ DCHECK(info->is_valid());
+
+ handle_ = info->PassHandle();
+ version_ = info->version();
+ runner_ = std::move(runner);
+}
+
+bool SimpleInterfacePtrState::ConfigureProxyIfNecessaryInternal(
+ const char* interface_name) {
+ // The object hasn't been bound.
+ if (!handle_.is_valid())
+ return false;
+
+ FilterChain filters;
+ filters.Append<MessageHeaderValidator>(interface_name);
+ filters.Append(CreateRequestValidator());
+
+ router_ = new Router(std::move(handle_), std::move(filters), false,
+ std::move(runner_));
+ return true;
+}
+
+void SimpleInterfacePtrState::OnQueryVersion(
+ const base::Callback<void(uint32_t)>& callback,
+ uint32_t version) {
+ version_ = version;
+ callback.Run(version);
+}
+
+} // namespace internal
+} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_ptr_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698