Index: ipc/attachment_broker.cc |
diff --git a/ipc/attachment_broker.cc b/ipc/attachment_broker.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9f811ce3ff08ae8fdbbb13434c364a86c28ecb29 |
--- /dev/null |
+++ b/ipc/attachment_broker.cc |
@@ -0,0 +1,37 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ipc/attachment_broker.h" |
+ |
+#include <algorithm> |
+ |
+namespace IPC { |
+ |
+AttachmentBroker::AttachmentBroker() { |
+} |
+AttachmentBroker::~AttachmentBroker() { |
+} |
+ |
+void AttachmentBroker::AddObserver(AttachmentBroker::Observer* observer) { |
+ auto it = std::find(observers_.begin(), observers_.end(), observer); |
+ if (it == observers_.end()) |
+ observers_.push_back(observer); |
+} |
+ |
+void AttachmentBroker::RemoveObserver(AttachmentBroker::Observer* observer) { |
+ auto it = std::find(observers_.begin(), observers_.end(), observer); |
+ if (it != observers_.end()) |
+ observers_.erase(it); |
+} |
+ |
+void AttachmentBroker::NotifyObservers( |
+ const BrokerableAttachment::AttachmentId& id) { |
+ // Make a copy of observers_ to avoid mutations during iteration. |
+ std::vector<Observer*> observers = observers_; |
+ for (Observer* observer : observers) { |
+ observer->ReceivedBrokerableAttachmentWithId(id); |
+ } |
+} |
+ |
+} // namespace IPC |