| OLD | NEW |
| 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 #include "ipc/attachment_broker.h" | 5 #include "ipc/attachment_broker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 *out_attachment = *it; | 42 *out_attachment = *it; |
| 43 attachments_.erase(it); | 43 attachments_.erase(it); |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void AttachmentBroker::AddObserver( | 50 void AttachmentBroker::AddObserver( |
| 51 AttachmentBroker::Observer* observer, | 51 AttachmentBroker::Observer* observer, |
| 52 const scoped_refptr<base::SequencedTaskRunner>& runner) { | 52 const scoped_refptr<base::TaskRunner>& runner) { |
| 53 base::AutoLock auto_lock(*get_lock()); | 53 base::AutoLock auto_lock(*get_lock()); |
| 54 auto it = std::find_if(observers_.begin(), observers_.end(), | 54 auto it = std::find_if(observers_.begin(), observers_.end(), |
| 55 [observer](const ObserverInfo& info) { | 55 [observer](const ObserverInfo& info) { |
| 56 return info.observer == observer; | 56 return info.observer == observer; |
| 57 }); | 57 }); |
| 58 if (it == observers_.end()) { | 58 if (it == observers_.end()) { |
| 59 ObserverInfo info; | 59 ObserverInfo info; |
| 60 info.observer = observer; | 60 info.observer = observer; |
| 61 info.runner = runner; | 61 info.runner = runner; |
| 62 info.unique_id = ++last_unique_id_; | 62 info.unique_id = ++last_unique_id_; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 observer = it->observer; | 123 observer = it->observer; |
| 124 } | 124 } |
| 125 | 125 |
| 126 observer->ReceivedBrokerableAttachmentWithId(id); | 126 observer->ReceivedBrokerableAttachmentWithId(id); |
| 127 } | 127 } |
| 128 | 128 |
| 129 AttachmentBroker::ObserverInfo::ObserverInfo() {} | 129 AttachmentBroker::ObserverInfo::ObserverInfo() {} |
| 130 AttachmentBroker::ObserverInfo::~ObserverInfo() {} | 130 AttachmentBroker::ObserverInfo::~ObserverInfo() {} |
| 131 | 131 |
| 132 } // namespace IPC | 132 } // namespace IPC |
| OLD | NEW |