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

Side by Side Diff: mojo/public/cpp/bindings/lib/interface_ptr_state.h

Issue 1535943002: Convert Pass()→std::move() in //mojo/public/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Regenerate correctly Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9
10 #include <algorithm> // For |std::swap()|. 9 #include <algorithm> // For |std::swap()|.
10 #include <utility>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "mojo/public/cpp/bindings/associated_group.h" 16 #include "mojo/public/cpp/bindings/associated_group.h"
17 #include "mojo/public/cpp/bindings/callback.h" 17 #include "mojo/public/cpp/bindings/callback.h"
18 #include "mojo/public/cpp/bindings/interface_ptr_info.h" 18 #include "mojo/public/cpp/bindings/interface_ptr_info.h"
19 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" 19 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
20 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 20 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ConfigureProxyIfNecessary(); 118 ConfigureProxyIfNecessary();
119 119
120 DCHECK(router_); 120 DCHECK(router_);
121 return router_->WaitForIncomingMessage(MOJO_DEADLINE_INDEFINITE); 121 return router_->WaitForIncomingMessage(MOJO_DEADLINE_INDEFINITE);
122 } 122 }
123 123
124 // After this method is called, the object is in an invalid state and 124 // After this method is called, the object is in an invalid state and
125 // shouldn't be reused. 125 // shouldn't be reused.
126 InterfacePtrInfo<GenericInterface> PassInterface() { 126 InterfacePtrInfo<GenericInterface> PassInterface() {
127 return InterfacePtrInfo<GenericInterface>( 127 return InterfacePtrInfo<GenericInterface>(
128 router_ ? router_->PassMessagePipe() : handle_.Pass(), version_); 128 router_ ? router_->PassMessagePipe() : std::move(handle_), version_);
129 } 129 }
130 130
131 bool is_bound() const { return handle_.is_valid() || router_; } 131 bool is_bound() const { return handle_.is_valid() || router_; }
132 132
133 bool encountered_error() const { 133 bool encountered_error() const {
134 return router_ ? router_->encountered_error() : false; 134 return router_ ? router_->encountered_error() : false;
135 } 135 }
136 136
137 void set_connection_error_handler(const Closure& error_handler) { 137 void set_connection_error_handler(const Closure& error_handler) {
138 ConfigureProxyIfNecessary(); 138 ConfigureProxyIfNecessary();
(...skipping 26 matching lines...) Expand all
165 // The object hasn't been bound. 165 // The object hasn't been bound.
166 if (!waiter_) { 166 if (!waiter_) {
167 DCHECK(!handle_.is_valid()); 167 DCHECK(!handle_.is_valid());
168 return; 168 return;
169 } 169 }
170 170
171 FilterChain filters; 171 FilterChain filters;
172 filters.Append<MessageHeaderValidator>(); 172 filters.Append<MessageHeaderValidator>();
173 filters.Append<typename Interface::ResponseValidator_>(); 173 filters.Append<typename Interface::ResponseValidator_>();
174 174
175 router_ = new Router(handle_.Pass(), filters.Pass(), waiter_); 175 router_ = new Router(std::move(handle_), std::move(filters), waiter_);
176 waiter_ = nullptr; 176 waiter_ = nullptr;
177 177
178 proxy_ = new Proxy(router_); 178 proxy_ = new Proxy(router_);
179 } 179 }
180 180
181 Proxy* proxy_; 181 Proxy* proxy_;
182 Router* router_; 182 Router* router_;
183 183
184 // |proxy_| and |router_| are not initialized until read/write with the 184 // |proxy_| and |router_| are not initialized until read/write with the
185 // message pipe handle is needed. |handle_| and |waiter_| are valid between 185 // message pipe handle is needed. |handle_| and |waiter_| are valid between
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 DCHECK(router_); 327 DCHECK(router_);
328 DCHECK(endpoint_client_); 328 DCHECK(endpoint_client_);
329 return; 329 return;
330 } 330 }
331 // The object hasn't been bound. 331 // The object hasn't been bound.
332 if (!waiter_) { 332 if (!waiter_) {
333 DCHECK(!handle_.is_valid()); 333 DCHECK(!handle_.is_valid());
334 return; 334 return;
335 } 335 }
336 336
337 router_ = new MultiplexRouter(true, handle_.Pass(), waiter_); 337 router_ = new MultiplexRouter(true, std::move(handle_), waiter_);
338 endpoint_client_.reset(new InterfaceEndpointClient( 338 endpoint_client_.reset(new InterfaceEndpointClient(
339 router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr, 339 router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr,
340 make_scoped_ptr(new typename Interface::ResponseValidator_()))); 340 make_scoped_ptr(new typename Interface::ResponseValidator_())));
341 proxy_.reset(new Proxy(endpoint_client_.get())); 341 proxy_.reset(new Proxy(endpoint_client_.get()));
342 proxy_->serialization_context()->router = endpoint_client_->router(); 342 proxy_->serialization_context()->router = endpoint_client_->router();
343 343
344 waiter_ = nullptr; 344 waiter_ = nullptr;
345 } 345 }
346 346
347 scoped_refptr<MultiplexRouter> router_; 347 scoped_refptr<MultiplexRouter> router_;
348 348
349 scoped_ptr<InterfaceEndpointClient> endpoint_client_; 349 scoped_ptr<InterfaceEndpointClient> endpoint_client_;
350 scoped_ptr<Proxy> proxy_; 350 scoped_ptr<Proxy> proxy_;
351 351
352 // |router_| (as well as other members above) is not initialized until 352 // |router_| (as well as other members above) is not initialized until
353 // read/write with the message pipe handle is needed. |handle_| and |waiter_| 353 // read/write with the message pipe handle is needed. |handle_| and |waiter_|
354 // are valid between the Bind() call and the initialization of |router_|. 354 // are valid between the Bind() call and the initialization of |router_|.
355 ScopedMessagePipeHandle handle_; 355 ScopedMessagePipeHandle handle_;
356 const MojoAsyncWaiter* waiter_; 356 const MojoAsyncWaiter* waiter_;
357 357
358 uint32_t version_; 358 uint32_t version_;
359 359
360 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); 360 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
361 }; 361 };
362 362
363 } // namespace internal 363 } // namespace internal
364 } // namespace mojo 364 } // namespace mojo
365 365
366 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ 366 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_endpoint_client.cc ('k') | mojo/public/cpp/bindings/lib/map_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698