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

Unified Diff: remoting/host/win/worker_process_launcher_unittest.cc

Issue 2448243004: Change WorkerProcessLauncherTest to use ChannelMojo. (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/win/worker_process_launcher_unittest.cc
diff --git a/remoting/host/win/worker_process_launcher_unittest.cc b/remoting/host/win/worker_process_launcher_unittest.cc
index caa8c66e29dea3e4e0fa5f3c055a1940de065169..c7af99f9154a3cba8e28f45706eea21ebefd9b2f 100644
--- a/remoting/host/win/worker_process_launcher_unittest.cc
+++ b/remoting/host/win/worker_process_launcher_unittest.cc
@@ -20,10 +20,10 @@
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_message.h"
+#include "mojo/public/cpp/system/message_pipe.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_messages.h"
#include "remoting/host/host_exit_codes.h"
-#include "remoting/host/ipc_util.h"
#include "remoting/host/win/launch_process_with_token.h"
#include "remoting/host/worker_process_ipc_delegate.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -44,8 +44,6 @@ namespace remoting {
namespace {
-const char kIpcSecurityDescriptor[] = "D:(A;;GA;;;AU)";
-
class MockProcessLauncherDelegate : public WorkerProcessLauncher::Delegate {
public:
MockProcessLauncherDelegate() {}
@@ -171,8 +169,8 @@ class WorkerProcessLauncherTest
// Implements WorkerProcessLauncher::Delegate.
std::unique_ptr<MockProcessLauncherDelegate> launcher_delegate_;
- // The name of the IPC channel.
- std::string channel_name_;
+ // The client handle to the channel.
+ mojo::ScopedMessagePipeHandle client_channel_handle_;
// Client and server ends of the IPC channel.
std::unique_ptr<IPC::ChannelProxy> channel_client_;
@@ -269,6 +267,7 @@ void WorkerProcessLauncherTest::FailLaunchAndStopWorker(
void WorkerProcessLauncherTest::KillProcess() {
event_handler_ = nullptr;
+ DisconnectClient();
if (worker_process_.IsValid()) {
TerminateProcess(worker_process_.Get(), CONTROL_C_EXIT);
worker_process_.Close();
@@ -281,10 +280,9 @@ void WorkerProcessLauncherTest::TerminateWorker(DWORD exit_code) {
}
void WorkerProcessLauncherTest::ConnectClient() {
- channel_client_ = IPC::ChannelProxy::Create(IPC::ChannelHandle(channel_name_),
+ channel_client_ = IPC::ChannelProxy::Create(client_channel_handle_.release(),
IPC::Channel::MODE_CLIENT,
- &client_listener_,
- task_runner_);
+ &client_listener_, task_runner_);
// Pretend that |kLaunchSuccessTimeoutSeconds| passed since launching
// the worker process. This will make the backoff algorithm think that this
@@ -293,11 +291,17 @@ void WorkerProcessLauncherTest::ConnectClient() {
}
void WorkerProcessLauncherTest::DisconnectClient() {
- channel_client_.reset();
+ if (channel_client_) {
+ channel_client_->Close();
+ channel_client_.reset();
+ }
}
void WorkerProcessLauncherTest::DisconnectServer() {
- channel_server_.reset();
+ if (channel_server_) {
+ channel_server_->Close();
+ channel_server_.reset();
+ }
}
void WorkerProcessLauncherTest::SendToProcess(IPC::Message* message) {
@@ -324,13 +328,14 @@ void WorkerProcessLauncherTest::StartWorker() {
launcher_.reset(new WorkerProcessLauncher(std::move(launcher_delegate_),
&server_listener_));
- launcher_->SetKillProcessTimeoutForTest(base::TimeDelta::FromMilliseconds(0));
+ launcher_->SetKillProcessTimeoutForTest(
+ base::TimeDelta::FromMilliseconds(100));
}
void WorkerProcessLauncherTest::StopWorker() {
launcher_.reset();
DisconnectClient();
- channel_name_.clear();
+ client_channel_handle_.reset();
channel_server_.reset();
task_runner_ = nullptr;
}
@@ -366,14 +371,12 @@ void WorkerProcessLauncherTest::DoLaunchProcess() {
worker_process_.Set(process_information.TakeProcessHandle());
ASSERT_TRUE(worker_process_.IsValid());
- channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID();
- ScopedHandle pipe;
- ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe));
+ mojo::MessagePipe pipe;
+ client_channel_handle_ = std::move(pipe.handle0);
// Wrap the pipe into an IPC channel.
channel_server_ = IPC::ChannelProxy::Create(
- IPC::ChannelHandle(pipe.Get()), IPC::Channel::MODE_SERVER, this,
- task_runner_);
+ pipe.handle1.release(), IPC::Channel::MODE_SERVER, this, task_runner_);
HANDLE temp_handle;
ASSERT_TRUE(DuplicateHandle(GetCurrentProcess(), worker_process_.Get(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698