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

Side by Side Diff: ipc/attachment_broker_privileged_win_unittest.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.cc ('k') | ipc/ipc_channel_nacl.h » ('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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 IPCTestBase::SetUp(); 147 IPCTestBase::SetUp();
148 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 148 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
149 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &temp_path_)); 149 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &temp_path_));
150 } 150 }
151 151
152 void TearDown() override { IPCTestBase::TearDown(); } 152 void TearDown() override { IPCTestBase::TearDown(); }
153 153
154 // Takes ownership of |broker|. Has no effect if called after CommonSetUp(). 154 // Takes ownership of |broker|. Has no effect if called after CommonSetUp().
155 void set_broker(IPC::AttachmentBrokerUnprivilegedWin* broker) { 155 void set_broker(IPC::AttachmentBrokerUnprivilegedWin* broker) {
156 broker_.reset(broker); 156 broker_.reset(broker);
157 IPC::AttachmentBroker::SetGlobal(broker);
157 } 158 }
158 159
159 void CommonSetUp() { 160 void CommonSetUp() {
160 if (!broker_.get()) 161 if (!broker_.get())
161 set_broker(new IPC::AttachmentBrokerUnprivilegedWin); 162 set_broker(new IPC::AttachmentBrokerUnprivilegedWin);
162 broker_->AddObserver(&observer_); 163 broker_->AddObserver(&observer_);
163 set_attachment_broker(broker_.get()); 164 set_attachment_broker(broker_.get());
164 CreateChannel(&proxy_listener_); 165 CreateChannel(&proxy_listener_);
165 broker_->DesignateBrokerCommunicationChannel(channel()); 166 broker_->DesignateBrokerCommunicationChannel(channel());
166 ASSERT_TRUE(ConnectChannel()); 167 ASSERT_TRUE(ConnectChannel());
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 IPC::AttachmentBrokerPrivilegedWin* broker, 337 IPC::AttachmentBrokerPrivilegedWin* broker,
337 IPC::Sender* sender); 338 IPC::Sender* sender);
338 339
339 int CommonPrivilegedProcessMain(OnMessageReceivedCallback callback, 340 int CommonPrivilegedProcessMain(OnMessageReceivedCallback callback,
340 const char* channel_name) { 341 const char* channel_name) {
341 base::MessageLoopForIO main_message_loop; 342 base::MessageLoopForIO main_message_loop;
342 ProxyListener listener; 343 ProxyListener listener;
343 344
344 // Set up IPC channel. 345 // Set up IPC channel.
345 IPC::AttachmentBrokerPrivilegedWin broker; 346 IPC::AttachmentBrokerPrivilegedWin broker;
346 listener.set_listener(&broker); 347 IPC::AttachmentBroker::SetGlobal(&broker);
347 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( 348 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
348 IPCTestBase::GetChannelName(channel_name), &listener, &broker)); 349 IPCTestBase::GetChannelName(channel_name), &listener, &broker));
349 broker.RegisterCommunicationChannel(channel.get()); 350 broker.RegisterCommunicationChannel(channel.get());
350 CHECK(channel->Connect()); 351 CHECK(channel->Connect());
351 352
352 MockObserver observer; 353 MockObserver observer;
353 broker.AddObserver(&observer); 354 broker.AddObserver(&observer);
354 355
355 while (true) { 356 while (true) {
356 base::MessageLoop::current()->Run(); 357 base::MessageLoop::current()->Run();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendHandleToSelf) { 424 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendHandleToSelf) {
424 return CommonPrivilegedProcessMain(&SendHandleToSelfCallback, 425 return CommonPrivilegedProcessMain(&SendHandleToSelfCallback,
425 "SendHandleToSelf"); 426 "SendHandleToSelf");
426 } 427 }
427 428
428 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendHandleWin) { 429 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendHandleWin) {
429 return CommonPrivilegedProcessMain(&SendHandleCallback, "SendHandleWin"); 430 return CommonPrivilegedProcessMain(&SendHandleCallback, "SendHandleWin");
430 } 431 }
431 432
432 } // namespace 433 } // namespace
OLDNEW
« no previous file with comments | « ipc/attachment_broker.cc ('k') | ipc/ipc_channel_nacl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698