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

Side by Side 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: Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ipc/attachment_broker.h"
6
7 namespace IPC {
8
9 AttachmentBroker::AttachmentBroker() {
10 }
11 AttachmentBroker::~AttachmentBroker() {
12 }
13
14 void AttachmentBroker::AddObserver(AttachmentBroker::Observer* observer) {
Tom Sepez 2015/07/13 18:28:47 do we care if |observer| has already been added?
erikchen 2015/07/17 18:44:00 I added logic to prevent the same observer from be
15 observers_.push_back(observer);
16 }
17
18 void AttachmentBroker::RemoveObserver(AttachmentBroker::Observer* observer) {
19 for (std::vector<Observer*>::iterator it = observers_.begin();
Tom Sepez 2015/07/13 18:28:47 can we use ::find here? How about auto keyword to
erikchen 2015/07/17 18:44:00 Used auto and find.
20 it != observers_.end(); ++it) {
21 if (*it == observer) {
22 observers_.erase(it);
23 break;
24 }
25 }
26 }
27
28 void AttachmentBroker::NotifyObservers(
29 const BrokerableAttachment::AttachmentId& id) {
30 // Make a copy of observers_ to avoid mutations during iteration.
31 std::vector<Observer*> observers = observers_;
32 for (Observer* observer : observers) {
33 observer->ReceivedBrokerableAttachmentWithId(id);
34 }
35 }
36
37 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698