Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_BINDING_SET_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_BINDING_SET_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_BINDING_SET_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_BINDING_SET_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 // context associated with the specific binding which received the message or | 88 // context associated with the specific binding which received the message or |
| 89 // error. Use AddBinding() to associated a context with a specific binding. | 89 // error. Use AddBinding() to associated a context with a specific binding. |
| 90 // | 90 // |
| 91 // Note that this may ONLY be called if the BindingSet was constructed with | 91 // Note that this may ONLY be called if the BindingSet was constructed with |
| 92 // |BindingSetDispatchMode::WITH_CONTEXT|. | 92 // |BindingSetDispatchMode::WITH_CONTEXT|. |
| 93 void* dispatch_context() const { | 93 void* dispatch_context() const { |
| 94 DCHECK(SupportsContext()); | 94 DCHECK(SupportsContext()); |
| 95 return dispatch_context_; | 95 return dispatch_context_; |
| 96 } | 96 } |
| 97 | 97 |
| 98 void FlushForTesting() { | |
| 99 for (auto& binding : bindings_) { | |
| 100 if (binding) | |
| 101 binding->FlushForTesting(); | |
|
yzshen1
2016/08/29 23:24:58
I guess this won't work because bindings_ is a map
Sam McNally
2016/08/30 03:05:51
It worked just fine last week ;)
| |
| 102 } | |
| 103 } | |
| 104 | |
| 98 private: | 105 private: |
| 99 friend class Entry; | 106 friend class Entry; |
| 100 | 107 |
| 101 class Entry { | 108 class Entry { |
| 102 public: | 109 public: |
| 103 Entry(Interface* impl, | 110 Entry(Interface* impl, |
| 104 RequestType request, | 111 RequestType request, |
| 105 BindingSet* binding_set, | 112 BindingSet* binding_set, |
| 106 void* context) | 113 void* context) |
| 107 : binding_(impl, std::move(request)), | 114 : binding_(impl, std::move(request)), |
| 108 binding_set_(binding_set), | 115 binding_set_(binding_set), |
| 109 context_(context) { | 116 context_(context) { |
| 110 if (binding_set->SupportsContext()) | 117 if (binding_set->SupportsContext()) |
| 111 binding_.AddFilter(base::MakeUnique<DispatchFilter>(this)); | 118 binding_.AddFilter(base::MakeUnique<DispatchFilter>(this)); |
| 112 binding_.set_connection_error_handler(base::Bind( | 119 binding_.set_connection_error_handler(base::Bind( |
| 113 &Entry::OnConnectionError, base::Unretained(this))); | 120 &Entry::OnConnectionError, base::Unretained(this))); |
| 114 } | 121 } |
| 115 | 122 |
| 123 void FlushForTesting() { binding_.FlushForTesting(); } | |
| 124 | |
| 116 private: | 125 private: |
| 117 class DispatchFilter : public MessageReceiver { | 126 class DispatchFilter : public MessageReceiver { |
| 118 public: | 127 public: |
| 119 explicit DispatchFilter(Entry* entry) : entry_(entry) {} | 128 explicit DispatchFilter(Entry* entry) : entry_(entry) {} |
| 120 ~DispatchFilter() override {} | 129 ~DispatchFilter() override {} |
| 121 | 130 |
| 122 private: | 131 private: |
| 123 // MessageReceiver: | 132 // MessageReceiver: |
| 124 bool Accept(Message* message) override { | 133 bool Accept(Message* message) override { |
| 125 entry_->WillDispatch(); | 134 entry_->WillDispatch(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 base::Closure error_handler_; | 180 base::Closure error_handler_; |
| 172 std::map<Entry*, std::unique_ptr<Entry>> bindings_; | 181 std::map<Entry*, std::unique_ptr<Entry>> bindings_; |
| 173 void* dispatch_context_ = nullptr; | 182 void* dispatch_context_ = nullptr; |
| 174 | 183 |
| 175 DISALLOW_COPY_AND_ASSIGN(BindingSet); | 184 DISALLOW_COPY_AND_ASSIGN(BindingSet); |
| 176 }; | 185 }; |
| 177 | 186 |
| 178 } // namespace mojo | 187 } // namespace mojo |
| 179 | 188 |
| 180 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_SET_H_ | 189 #endif // MOJO_PUBLIC_CPP_BINDINGS_BINDING_SET_H_ |
| OLD | NEW |