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

Side by Side Diff: mojo/common/weak_binding_set.h

Issue 1262613005: Remove interface_impl.h and error_handler.h usage from chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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 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_COMMON_WEAK_BINDING_SET_H_ 5 #ifndef MOJO_COMMON_WEAK_BINDING_SET_H_
6 #define MOJO_COMMON_WEAK_BINDING_SET_H_ 6 #define MOJO_COMMON_WEAK_BINDING_SET_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 10 matching lines...) Expand all
21 template <typename Interface> 21 template <typename Interface>
22 class WeakBindingSet { 22 class WeakBindingSet {
23 public: 23 public:
24 WeakBindingSet() {} 24 WeakBindingSet() {}
25 ~WeakBindingSet() { CloseAllBindings(); } 25 ~WeakBindingSet() { CloseAllBindings(); }
26 26
27 void set_connection_error_handler(const Closure& error_handler) { 27 void set_connection_error_handler(const Closure& error_handler) {
28 error_handler_ = error_handler; 28 error_handler_ = error_handler;
29 } 29 }
30 30
31 // NOTE: Deprecated. Please use the method above.
32 // TODO(yzshen): Remove this method once all callsites are converted.
33 void set_error_handler(ErrorHandler* error_handler) {
34 if (error_handler) {
35 set_connection_error_handler(
36 [error_handler]() { error_handler->OnConnectionError(); });
37 } else {
38 set_connection_error_handler(Closure());
39 }
40 }
41
42 void AddBinding(Interface* impl, InterfaceRequest<Interface> request) { 31 void AddBinding(Interface* impl, InterfaceRequest<Interface> request) {
43 auto binding = new WeakBinding<Interface>(impl, request.Pass()); 32 auto binding = new WeakBinding<Interface>(impl, request.Pass());
44 binding->set_connection_error_handler([this]() { OnConnectionError(); }); 33 binding->set_connection_error_handler([this]() { OnConnectionError(); });
45 bindings_.push_back(binding->GetWeakPtr()); 34 bindings_.push_back(binding->GetWeakPtr());
46 } 35 }
47 36
48 void CloseAllBindings() { 37 void CloseAllBindings() {
49 for (const auto& it : bindings_) { 38 for (const auto& it : bindings_) {
50 if (it) 39 if (it)
51 it->Close(); 40 it->Close();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 Binding<Interface> binding_; 94 Binding<Interface> binding_;
106 Closure error_handler_; 95 Closure error_handler_;
107 base::WeakPtrFactory<WeakBinding> weak_ptr_factory_; 96 base::WeakPtrFactory<WeakBinding> weak_ptr_factory_;
108 97
109 DISALLOW_COPY_AND_ASSIGN(WeakBinding); 98 DISALLOW_COPY_AND_ASSIGN(WeakBinding);
110 }; 99 };
111 100
112 } // namespace mojo 101 } // namespace mojo
113 102
114 #endif // MOJO_COMMON_WEAK_BINDING_SET_H_ 103 #endif // MOJO_COMMON_WEAK_BINDING_SET_H_
OLDNEW
« no previous file with comments | « mojo/application/public/cpp/interface_factory.h ('k') | mojo/runner/out_of_process_native_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698