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

Side by Side Diff: mojo/public/cpp/bindings/associated_interface_request.h

Issue 2031823002: Mojo C++ bindings: more consistent Clone() and Equals(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ASSOCIATED_INTERFACE_REQUEST_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 void Bind(ScopedInterfaceEndpointHandle handle) { 50 void Bind(ScopedInterfaceEndpointHandle handle) {
51 handle_ = std::move(handle); 51 handle_ = std::move(handle);
52 } 52 }
53 53
54 ScopedInterfaceEndpointHandle PassHandle() { 54 ScopedInterfaceEndpointHandle PassHandle() {
55 return std::move(handle_); 55 return std::move(handle_);
56 } 56 }
57 57
58 const ScopedInterfaceEndpointHandle& handle() const { return handle_; } 58 const ScopedInterfaceEndpointHandle& handle() const { return handle_; }
59 59
60 bool Equals(const AssociatedInterfaceRequest& other) const {
61 if (this == &other)
62 return true;
63
64 // Now that the two refer to different objects, they are equivalent if
65 // and only if they are both invalid.
66 return !is_pending() && !other.is_pending();
67 }
68
60 private: 69 private:
61 ScopedInterfaceEndpointHandle handle_; 70 ScopedInterfaceEndpointHandle handle_;
62 }; 71 };
63 72
64 // Makes an AssociatedInterfaceRequest bound to the specified associated 73 // Makes an AssociatedInterfaceRequest bound to the specified associated
65 // endpoint. 74 // endpoint.
66 template <typename Interface> 75 template <typename Interface>
67 AssociatedInterfaceRequest<Interface> MakeAssociatedRequest( 76 AssociatedInterfaceRequest<Interface> MakeAssociatedRequest(
68 ScopedInterfaceEndpointHandle handle) { 77 ScopedInterfaceEndpointHandle handle) {
69 AssociatedInterfaceRequest<Interface> request; 78 AssociatedInterfaceRequest<Interface> request;
70 request.Bind(std::move(handle)); 79 request.Bind(std::move(handle));
71 return request; 80 return request;
72 } 81 }
73 82
74 } // namespace mojo 83 } // namespace mojo
75 84
76 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_ 85 #endif // MOJO_PUBLIC_CPP_BINDINGS_ASSOCIATED_INTERFACE_REQUEST_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/associated_interface_ptr_info.h ('k') | mojo/public/cpp/bindings/interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698