| 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_APPLICATION_LIB_SERVICE_CONNECTOR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ |
| 6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ | 6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include <assert.h> | 8 #include <assert.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 connections_.push_back(impl); | 116 connections_.push_back(impl); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void RemoveConnection(ServiceImpl* impl) { | 119 void RemoveConnection(ServiceImpl* impl) { |
| 120 // Called from ~ServiceImpl, in response to a connection error. | 120 // Called from ~ServiceImpl, in response to a connection error. |
| 121 for (typename ConnectionList::iterator it = connections_.begin(); | 121 for (typename ConnectionList::iterator it = connections_.begin(); |
| 122 it != connections_.end(); ++it) { | 122 it != connections_.end(); ++it) { |
| 123 if (*it == impl) { | 123 if (*it == impl) { |
| 124 delete impl; | 124 delete impl; |
| 125 connections_.erase(it); | 125 connections_.erase(it); |
| 126 if (connections_.empty()) | |
| 127 owner_->RemoveServiceConnector(this); | |
| 128 return; | 126 return; |
| 129 } | 127 } |
| 130 } | 128 } |
| 131 } | 129 } |
| 132 | 130 |
| 133 Context* context() const { return context_; } | 131 Context* context() const { return context_; } |
| 134 | 132 |
| 135 private: | 133 private: |
| 136 typedef std::vector<ServiceImpl*> ConnectionList; | 134 typedef std::vector<ServiceImpl*> ConnectionList; |
| 137 ConnectionList connections_; | 135 ConnectionList connections_; |
| 138 Context* context_; | 136 Context* context_; |
| 139 }; | 137 }; |
| 140 | 138 |
| 141 } // namespace internal | 139 } // namespace internal |
| 142 } // namespace mojo | 140 } // namespace mojo |
| 143 | 141 |
| 144 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ | 142 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ |
| OLD | NEW |