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

Unified Diff: ipc/attachment_broker.cc

Issue 1206093002: Update ChannelReader to use AttachmentBroker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attachment_broker3_listener
Patch Set: Comments from tsepez. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/attachment_broker.h ('k') | ipc/attachment_broker_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ipc/attachment_broker.h ('k') | ipc/attachment_broker_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698