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

Side by Side Diff: mojo/public/cpp/bindings/lib/binding_state.cc

Issue 2280483002: Add FlushForTesting to InterfacePtr and Binding. (Closed)
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/bindings/lib/binding_state.h" 5 #include "mojo/public/cpp/bindings/lib/binding_state.h"
6 6
7 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
8
7 namespace mojo { 9 namespace mojo {
8 namespace internal { 10 namespace internal {
9 11
10 SimpleBindingState::SimpleBindingState() = default; 12 SimpleBindingState::SimpleBindingState() = default;
11 13
12 SimpleBindingState::~SimpleBindingState() = default; 14 SimpleBindingState::~SimpleBindingState() = default;
13 15
14 void SimpleBindingState::AddFilter(std::unique_ptr<MessageReceiver> filter) { 16 void SimpleBindingState::AddFilter(std::unique_ptr<MessageReceiver> filter) {
15 DCHECK(router_); 17 DCHECK(router_);
16 router_->AddFilter(std::move(filter)); 18 router_->AddFilter(std::move(filter));
(...skipping 14 matching lines...) Expand all
31 } 33 }
32 34
33 void SimpleBindingState::Close() { 35 void SimpleBindingState::Close() {
34 if (!router_) 36 if (!router_)
35 return; 37 return;
36 38
37 router_->CloseMessagePipe(); 39 router_->CloseMessagePipe();
38 DestroyRouter(); 40 DestroyRouter();
39 } 41 }
40 42
43 void SimpleBindingState::FlushForTesting() {
44 router_->control_message_proxy()->FlushForTesting();
45 }
46
41 void SimpleBindingState::EnableTestingMode() { 47 void SimpleBindingState::EnableTestingMode() {
42 DCHECK(is_bound()); 48 DCHECK(is_bound());
43 router_->EnableTestingMode(); 49 router_->EnableTestingMode();
44 } 50 }
45 51
46 void SimpleBindingState::BindInternal( 52 void SimpleBindingState::BindInternal(
47 ScopedMessagePipeHandle handle, 53 ScopedMessagePipeHandle handle,
48 scoped_refptr<base::SingleThreadTaskRunner> runner, 54 scoped_refptr<base::SingleThreadTaskRunner> runner,
49 const char* interface_name, 55 const char* interface_name,
50 std::unique_ptr<MessageReceiver> request_validator, 56 std::unique_ptr<MessageReceiver> request_validator,
51 bool has_sync_methods, 57 bool has_sync_methods,
52 MessageReceiverWithResponderStatus* stub) { 58 MessageReceiverWithResponderStatus* stub,
59 uint32_t interface_version) {
53 FilterChain filters; 60 FilterChain filters;
54 filters.Append<MessageHeaderValidator>(interface_name); 61 filters.Append<MessageHeaderValidator>(interface_name);
55 filters.Append(std::move(request_validator)); 62 filters.Append(std::move(request_validator));
56 63
57 router_ = new internal::Router(std::move(handle), std::move(filters), 64 router_ = new internal::Router(std::move(handle), std::move(filters),
58 has_sync_methods, std::move(runner)); 65 has_sync_methods, std::move(runner),
66 interface_version);
59 router_->set_incoming_receiver(stub); 67 router_->set_incoming_receiver(stub);
60 router_->set_connection_error_handler(base::Bind( 68 router_->set_connection_error_handler(base::Bind(
61 &SimpleBindingState::RunConnectionErrorHandler, base::Unretained(this))); 69 &SimpleBindingState::RunConnectionErrorHandler, base::Unretained(this)));
62 } 70 }
63 71
64 void SimpleBindingState::DestroyRouter() { 72 void SimpleBindingState::DestroyRouter() {
65 router_->set_connection_error_handler(base::Closure()); 73 router_->set_connection_error_handler(base::Closure());
66 delete router_; 74 delete router_;
67 router_ = nullptr; 75 router_ = nullptr;
68 connection_error_handler_.Reset(); 76 connection_error_handler_.Reset();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void MultiplexedBindingState::Close() { 114 void MultiplexedBindingState::Close() {
107 if (!router_) 115 if (!router_)
108 return; 116 return;
109 117
110 endpoint_client_.reset(); 118 endpoint_client_.reset();
111 router_->CloseMessagePipe(); 119 router_->CloseMessagePipe();
112 router_ = nullptr; 120 router_ = nullptr;
113 connection_error_handler_.Reset(); 121 connection_error_handler_.Reset();
114 } 122 }
115 123
124 void MultiplexedBindingState::FlushForTesting() {
125 endpoint_client_->control_message_proxy()->FlushForTesting();
126 }
127
116 void MultiplexedBindingState::EnableTestingMode() { 128 void MultiplexedBindingState::EnableTestingMode() {
117 DCHECK(is_bound()); 129 DCHECK(is_bound());
118 router_->EnableTestingMode(); 130 router_->EnableTestingMode();
119 } 131 }
120 132
121 void MultiplexedBindingState::BindInternal( 133 void MultiplexedBindingState::BindInternal(
122 ScopedMessagePipeHandle handle, 134 ScopedMessagePipeHandle handle,
123 scoped_refptr<base::SingleThreadTaskRunner> runner, 135 scoped_refptr<base::SingleThreadTaskRunner> runner,
124 const char* interface_name, 136 const char* interface_name,
125 std::unique_ptr<MessageReceiver> request_validator, 137 std::unique_ptr<MessageReceiver> request_validator,
126 bool has_sync_methods, 138 bool has_sync_methods,
127 MessageReceiverWithResponderStatus* stub) { 139 MessageReceiverWithResponderStatus* stub,
140 uint32_t interface_version) {
128 DCHECK(!router_); 141 DCHECK(!router_);
129 142
130 router_ = new internal::MultiplexRouter(false, std::move(handle), runner); 143 router_ = new internal::MultiplexRouter(false, std::move(handle), runner);
131 router_->SetMasterInterfaceName(interface_name); 144 router_->SetMasterInterfaceName(interface_name);
132 145
133 endpoint_client_.reset(new InterfaceEndpointClient( 146 endpoint_client_.reset(new InterfaceEndpointClient(
134 router_->CreateLocalEndpointHandle(kMasterInterfaceId), stub, 147 router_->CreateLocalEndpointHandle(kMasterInterfaceId), stub,
135 std::move(request_validator), has_sync_methods, std::move(runner))); 148 std::move(request_validator), has_sync_methods, std::move(runner),
149 interface_version));
136 150
137 endpoint_client_->set_connection_error_handler( 151 endpoint_client_->set_connection_error_handler(
138 base::Bind(&MultiplexedBindingState::RunConnectionErrorHandler, 152 base::Bind(&MultiplexedBindingState::RunConnectionErrorHandler,
139 base::Unretained(this))); 153 base::Unretained(this)));
140 } 154 }
141 155
142 void MultiplexedBindingState::RunConnectionErrorHandler() { 156 void MultiplexedBindingState::RunConnectionErrorHandler() {
143 if (!connection_error_handler_.is_null()) 157 if (!connection_error_handler_.is_null())
144 connection_error_handler_.Run(); 158 connection_error_handler_.Run();
145 } 159 }
146 160
147 } // namesapce internal 161 } // namesapce internal
148 } // namespace mojo 162 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/binding_state.h ('k') | mojo/public/cpp/bindings/lib/control_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698