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

Side by Side Diff: ipc/attachment_broker.cc

Issue 1292263003: ipc: Use a global for the process's attachment broker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_message2
Patch Set: Comments from avi. Created 5 years, 3 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
« no previous file with comments | « ipc/attachment_broker.h ('k') | ipc/attachment_broker_privileged_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 namespace {
10 IPC::AttachmentBroker* g_attachment_broker = nullptr;
11 }
12
9 namespace IPC { 13 namespace IPC {
10 14
15 // static
16 void AttachmentBroker::SetGlobal(AttachmentBroker* broker) {
17 CHECK(!g_attachment_broker);
18 g_attachment_broker = broker;
19 }
20
21 // static
22 AttachmentBroker* AttachmentBroker::GetGlobal() {
23 return g_attachment_broker;
24 }
25
11 AttachmentBroker::AttachmentBroker() {} 26 AttachmentBroker::AttachmentBroker() {}
12 AttachmentBroker::~AttachmentBroker() {} 27 AttachmentBroker::~AttachmentBroker() {}
13 28
14 bool AttachmentBroker::GetAttachmentWithId( 29 bool AttachmentBroker::GetAttachmentWithId(
15 BrokerableAttachment::AttachmentId id, 30 BrokerableAttachment::AttachmentId id,
16 scoped_refptr<BrokerableAttachment>* out_attachment) { 31 scoped_refptr<BrokerableAttachment>* out_attachment) {
17 for (AttachmentVector::iterator it = attachments_.begin(); 32 for (AttachmentVector::iterator it = attachments_.begin();
18 it != attachments_.end(); ++it) { 33 it != attachments_.end(); ++it) {
19 if ((*it)->GetIdentifier() == id) { 34 if ((*it)->GetIdentifier() == id) {
20 *out_attachment = *it; 35 *out_attachment = *it;
(...skipping 25 matching lines...) Expand all
46 void AttachmentBroker::NotifyObservers( 61 void AttachmentBroker::NotifyObservers(
47 const BrokerableAttachment::AttachmentId& id) { 62 const BrokerableAttachment::AttachmentId& id) {
48 // Make a copy of observers_ to avoid mutations during iteration. 63 // Make a copy of observers_ to avoid mutations during iteration.
49 std::vector<Observer*> observers = observers_; 64 std::vector<Observer*> observers = observers_;
50 for (Observer* observer : observers) { 65 for (Observer* observer : observers) {
51 observer->ReceivedBrokerableAttachmentWithId(id); 66 observer->ReceivedBrokerableAttachmentWithId(id);
52 } 67 }
53 } 68 }
54 69
55 } // namespace IPC 70 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/attachment_broker.h ('k') | ipc/attachment_broker_privileged_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698