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

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 1903663004: IPC: Fix attachment brokering race condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (scoped_ptr->std::unique_ptr) Created 4 years, 7 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 | « remoting/host/ipc_util_win.cc ('k') | remoting/host/win/unprivileged_process_delegate.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 466
467 #if defined(OS_WIN) 467 #if defined(OS_WIN)
468 base::win::ScopedHandle pipe(reinterpret_cast<HANDLE>(pipe_handle)); 468 base::win::ScopedHandle pipe(reinterpret_cast<HANDLE>(pipe_handle));
469 IPC::ChannelHandle channel_handle(pipe.Get()); 469 IPC::ChannelHandle channel_handle(pipe.Get());
470 #elif defined(OS_POSIX) 470 #elif defined(OS_POSIX)
471 base::FileDescriptor pipe(pipe_handle, true); 471 base::FileDescriptor pipe(pipe_handle, true);
472 IPC::ChannelHandle channel_handle(channel_name, pipe); 472 IPC::ChannelHandle channel_handle(channel_name, pipe);
473 #endif // defined(OS_POSIX) 473 #endif // defined(OS_POSIX)
474 474
475 // Connect to the daemon process. 475 // Connect to the daemon process.
476 daemon_channel_ = IPC::ChannelProxy::Create(channel_handle, 476 daemon_channel_.reset(
477 IPC::Channel::MODE_CLIENT, 477 new IPC::ChannelProxy(this, context_->network_task_runner()));
478 this,
479 context_->network_task_runner());
480
481 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); 478 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
482 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 479 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
483 if (broker && !broker->IsPrivilegedBroker()) 480 if (broker && !broker->IsPrivilegedBroker())
484 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get()); 481 broker->RegisterBrokerCommunicationChannel(daemon_channel_.get());
482 daemon_channel_->Init(channel_handle, IPC::Channel::MODE_CLIENT, true);
485 483
486 #else // !defined(REMOTING_MULTI_PROCESS) 484 #else // !defined(REMOTING_MULTI_PROCESS)
487 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { 485 if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
488 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); 486 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
489 487
490 // Read config from stdin if necessary. 488 // Read config from stdin if necessary.
491 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { 489 if (host_config_path_ == base::FilePath(kStdinConfigPath)) {
492 const size_t kBufferSize = 4096; 490 const size_t kBufferSize = 4096;
493 std::unique_ptr<char[]> buf(new char[kBufferSize]); 491 std::unique_ptr<char[]> buf(new char[kBufferSize]);
494 size_t len; 492 size_t len;
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); 1650 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds));
1653 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog); 1651 new HostProcess(std::move(context), &exit_code, &shutdown_watchdog);
1654 1652
1655 // Run the main (also UI) message loop until the host no longer needs it. 1653 // Run the main (also UI) message loop until the host no longer needs it.
1656 message_loop.Run(); 1654 message_loop.Run();
1657 1655
1658 return exit_code; 1656 return exit_code;
1659 } 1657 }
1660 1658
1661 } // namespace remoting 1659 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/ipc_util_win.cc ('k') | remoting/host/win/unprivileged_process_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698