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

Side by Side Diff: ipc/attachment_broker_mac_unittest.cc

Issue 1411523006: mac: Make Mach port scopers better ScopedGenerics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 5 years, 2 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 | « content/child/child_io_surface_manager_mac.cc ('k') | ipc/attachment_broker_privileged_mac.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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 376
377 if (!broker_.get()) 377 if (!broker_.get())
378 SetBroker(new IPC::AttachmentBrokerUnprivilegedMac); 378 SetBroker(new IPC::AttachmentBrokerUnprivilegedMac);
379 379
380 broker_->AddObserver(&observer_); 380 broker_->AddObserver(&observer_);
381 CreateChannel(&proxy_listener_); 381 CreateChannel(&proxy_listener_);
382 broker_->DesignateBrokerCommunicationChannel(channel()); 382 broker_->DesignateBrokerCommunicationChannel(channel());
383 ASSERT_TRUE(ConnectChannel()); 383 ASSERT_TRUE(ConnectChannel());
384 ASSERT_TRUE(StartClient()); 384 ASSERT_TRUE(StartClient());
385 385
386 client_port_.reset(IPC::ReceiveMachPort(server_port_).release()); 386 client_port_.reset(IPC::ReceiveMachPort(server_port_.get()).release());
387 IPC::SendMachPort(client_port_, mach_task_self(), MACH_MSG_TYPE_COPY_SEND); 387 IPC::SendMachPort(
388 client_port_.get(), mach_task_self(), MACH_MSG_TYPE_COPY_SEND);
388 active_names_at_start_ = IPC::GetActiveNameCount(); 389 active_names_at_start_ = IPC::GetActiveNameCount();
389 get_proxy_listener()->set_listener(&result_listener_); 390 get_proxy_listener()->set_listener(&result_listener_);
390 } 391 }
391 392
392 void CheckChildResult() { 393 void CheckChildResult() {
393 ASSERT_EQ(ProxyListener::MESSAGE_RECEIVED, 394 ASSERT_EQ(ProxyListener::MESSAGE_RECEIVED,
394 get_proxy_listener()->get_reason()); 395 get_proxy_listener()->get_reason());
395 ASSERT_EQ(get_result_listener()->get_result(), RESULT_SUCCESS); 396 ASSERT_EQ(get_result_listener()->get_result(), RESULT_SUCCESS);
396 } 397 }
397 398
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 // globals that must live at least as long as the test. 464 // globals that must live at least as long as the test.
464 scoped_ptr<ChildProcessGlobals> CommonChildProcessSetUp() { 465 scoped_ptr<ChildProcessGlobals> CommonChildProcessSetUp() {
465 base::CommandLine cmd_line = *base::CommandLine::ForCurrentProcess(); 466 base::CommandLine cmd_line = *base::CommandLine::ForCurrentProcess();
466 std::string service_name = 467 std::string service_name =
467 cmd_line.GetSwitchValueASCII(g_service_switch_name); 468 cmd_line.GetSwitchValueASCII(g_service_switch_name);
468 base::mac::ScopedMachSendRight server_port( 469 base::mac::ScopedMachSendRight server_port(
469 IPC::LookupServer(service_name.c_str())); 470 IPC::LookupServer(service_name.c_str()));
470 base::mac::ScopedMachReceiveRight client_port(IPC::MakeReceivingPort()); 471 base::mac::ScopedMachReceiveRight client_port(IPC::MakeReceivingPort());
471 472
472 // Send the port that this process is listening on to the server. 473 // Send the port that this process is listening on to the server.
473 IPC::SendMachPort(server_port, client_port, MACH_MSG_TYPE_MAKE_SEND); 474 IPC::SendMachPort(
475 server_port.get(), client_port.get(), MACH_MSG_TYPE_MAKE_SEND);
474 476
475 // Receive the task port of the server process. 477 // Receive the task port of the server process.
476 base::mac::ScopedMachSendRight server_task_port( 478 base::mac::ScopedMachSendRight server_task_port(
477 IPC::ReceiveMachPort(client_port)); 479 IPC::ReceiveMachPort(client_port.get()));
478 480
479 scoped_ptr<ChildProcessGlobals> globals(new ChildProcessGlobals); 481 scoped_ptr<ChildProcessGlobals> globals(new ChildProcessGlobals);
480 globals->port_provider.InsertEntry(getppid(), server_task_port); 482 globals->port_provider.InsertEntry(getppid(), server_task_port.get());
481 globals->broker.SetPortProvider(&globals->port_provider); 483 globals->broker.SetPortProvider(&globals->port_provider);
482 globals->server_task_port.reset(server_task_port.release()); 484 globals->server_task_port.reset(server_task_port.release());
483 return globals; 485 return globals;
484 } 486 }
485 487
486 int CommonPrivilegedProcessMain(OnMessageReceivedCallback callback, 488 int CommonPrivilegedProcessMain(OnMessageReceivedCallback callback,
487 const char* channel_name) { 489 const char* channel_name) {
488 LOG(INFO) << "Privileged process start."; 490 LOG(INFO) << "Privileged process start.";
489 scoped_ptr<ChildProcessGlobals> globals(CommonChildProcessSetUp()); 491 scoped_ptr<ChildProcessGlobals> globals(CommonChildProcessSetUp());
490 492
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 // Do nothing special. The default behavior already runs the 831 // Do nothing special. The default behavior already runs the
830 // AttachmentBrokerPrivilegedMac. 832 // AttachmentBrokerPrivilegedMac.
831 } 833 }
832 834
833 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendSharedMemoryHandleToSelf) { 835 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SendSharedMemoryHandleToSelf) {
834 return CommonPrivilegedProcessMain(&SendSharedMemoryHandleToSelfCallback, 836 return CommonPrivilegedProcessMain(&SendSharedMemoryHandleToSelfCallback,
835 "SendSharedMemoryHandleToSelf"); 837 "SendSharedMemoryHandleToSelf");
836 } 838 }
837 839
838 } // namespace 840 } // namespace
OLDNEW
« no previous file with comments | « content/child/child_io_surface_manager_mac.cc ('k') | ipc/attachment_broker_privileged_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698