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

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

Issue 2047633002: Revert of Remove base/move.h (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 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_STRONG_BINDING_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h"
12 #include "mojo/public/cpp/bindings/binding.h" 11 #include "mojo/public/cpp/bindings/binding.h"
13 #include "mojo/public/cpp/bindings/callback.h" 12 #include "mojo/public/cpp/bindings/callback.h"
14 #include "mojo/public/cpp/bindings/interface_ptr.h" 13 #include "mojo/public/cpp/bindings/interface_ptr.h"
15 #include "mojo/public/cpp/bindings/interface_request.h" 14 #include "mojo/public/cpp/bindings/interface_request.h"
16 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 15 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
17 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" 16 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
18 #include "mojo/public/cpp/bindings/lib/router.h" 17 #include "mojo/public/cpp/bindings/lib/router.h"
19 #include "mojo/public/cpp/system/core.h" 18 #include "mojo/public/cpp/system/core.h"
20 19
21 namespace mojo { 20 namespace mojo {
(...skipping 20 matching lines...) Expand all
42 // void Create(..., InterfaceRequest<Foo> request) override { 41 // void Create(..., InterfaceRequest<Foo> request) override {
43 // new StronglyBound(std::move(request)); // The binding now owns the 42 // new StronglyBound(std::move(request)); // The binding now owns the
44 // // instance of StronglyBound. 43 // // instance of StronglyBound.
45 // } 44 // }
46 // }; 45 // };
47 // 46 //
48 // This class is thread hostile once it is bound to a message pipe. Until it is 47 // This class is thread hostile once it is bound to a message pipe. Until it is
49 // bound, it may be bound or destroyed on any thread. 48 // bound, it may be bound or destroyed on any thread.
50 template <typename Interface> 49 template <typename Interface>
51 class StrongBinding { 50 class StrongBinding {
51 MOVE_ONLY_TYPE_FOR_CPP_03(StrongBinding);
52
52 public: 53 public:
53 explicit StrongBinding(Interface* impl) : binding_(impl) {} 54 explicit StrongBinding(Interface* impl) : binding_(impl) {}
54 55
55 StrongBinding(Interface* impl, ScopedMessagePipeHandle handle) 56 StrongBinding(Interface* impl, ScopedMessagePipeHandle handle)
56 : StrongBinding(impl) { 57 : StrongBinding(impl) {
57 Bind(std::move(handle)); 58 Bind(std::move(handle));
58 } 59 }
59 60
60 StrongBinding(Interface* impl, InterfacePtr<Interface>* ptr) 61 StrongBinding(Interface* impl, InterfacePtr<Interface>* ptr)
61 : StrongBinding(impl) { 62 : StrongBinding(impl) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 internal::Router* internal_router() { return binding_.internal_router(); } 106 internal::Router* internal_router() { return binding_.internal_router(); }
106 107
107 void OnConnectionError() { 108 void OnConnectionError() {
108 connection_error_handler_.Run(); 109 connection_error_handler_.Run();
109 delete binding_.impl(); 110 delete binding_.impl();
110 } 111 }
111 112
112 private: 113 private:
113 Closure connection_error_handler_; 114 Closure connection_error_handler_;
114 Binding<Interface> binding_; 115 Binding<Interface> binding_;
115
116 DISALLOW_COPY_AND_ASSIGN(StrongBinding);
117 }; 116 };
118 117
119 } // namespace mojo 118 } // namespace mojo
120 119
121 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_ 120 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRONG_BINDING_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h ('k') | mojo/public/cpp/bindings/struct_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698