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

Side by Side Diff: ipc/ipc_test_base.cc

Issue 536213002: Add ipc_mojo_perftests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed garbage Created 6 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/ipc_test_base.h ('k') | ipc/mojo/BUILD.gn » ('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 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "ipc/ipc_test_base.h" 7 #include "ipc/ipc_test_base.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/process/kill.h" 10 #include "base/process/kill.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 scoped_ptr<base::MessageLoop> message_loop) { 45 scoped_ptr<base::MessageLoop> message_loop) {
46 DCHECK(!test_client_name.empty()); 46 DCHECK(!test_client_name.empty());
47 DCHECK(test_client_name_.empty()); 47 DCHECK(test_client_name_.empty());
48 DCHECK(!message_loop_); 48 DCHECK(!message_loop_);
49 49
50 test_client_name_ = test_client_name; 50 test_client_name_ = test_client_name;
51 message_loop_ = message_loop.Pass(); 51 message_loop_ = message_loop.Pass();
52 } 52 }
53 53
54 void IPCTestBase::CreateChannel(IPC::Listener* listener) { 54 void IPCTestBase::CreateChannel(IPC::Listener* listener) {
55 return CreateChannelFromChannelHandle(GetChannelName(test_client_name_), 55 CreateChannelFromChannelHandle(
56 listener); 56 GetChannelName(test_client_name_), listener);
57 } 57 }
58 58
59 bool IPCTestBase::ConnectChannel() { 59 bool IPCTestBase::ConnectChannel() {
60 CHECK(channel_.get()); 60 CHECK(channel_.get());
61 return channel_->Connect(); 61 return channel_->Connect();
62 } 62 }
63 63
64 scoped_ptr<IPC::Channel> IPCTestBase::ReleaseChannel() { 64 scoped_ptr<IPC::Channel> IPCTestBase::ReleaseChannel() {
65 return channel_.Pass(); 65 return channel_.Pass();
66 } 66 }
67 67
68 void IPCTestBase::SetChannel(scoped_ptr<IPC::Channel> channel) { 68 void IPCTestBase::SetChannel(scoped_ptr<IPC::Channel> channel) {
69 channel_ = channel.Pass(); 69 channel_ = channel.Pass();
70 } 70 }
71 71
72 72
73 void IPCTestBase::DestroyChannel() { 73 void IPCTestBase::DestroyChannel() {
74 DCHECK(channel_.get()); 74 DCHECK(channel_.get());
75 channel_.reset(); 75 channel_.reset();
76 } 76 }
77 77
78 void IPCTestBase::CreateChannelFromChannelHandle( 78 void IPCTestBase::CreateChannelFromChannelHandle(
79 const IPC::ChannelHandle& channel_handle, 79 const IPC::ChannelHandle& channel_handle,
80 IPC::Listener* listener) { 80 IPC::Listener* listener) {
81 CHECK(!channel_.get()); 81 CHECK(!channel_.get());
82 CHECK(!channel_proxy_.get()); 82 CHECK(!channel_proxy_.get());
83 channel_ = IPC::Channel::CreateServer(channel_handle, listener); 83 channel_ = CreateChannelFactory(
84 channel_handle, task_runner().get())->BuildChannel(listener);
84 } 85 }
85 86
86 void IPCTestBase::CreateChannelProxy( 87 void IPCTestBase::CreateChannelProxy(
87 IPC::Listener* listener, 88 IPC::Listener* listener,
88 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { 89 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
89 CHECK(!channel_.get()); 90 CHECK(!channel_.get());
90 CHECK(!channel_proxy_.get()); 91 CHECK(!channel_proxy_.get());
91 channel_proxy_ = IPC::ChannelProxy::Create(GetChannelName(test_client_name_), 92 channel_proxy_ = IPC::ChannelProxy::Create(
92 IPC::Channel::MODE_SERVER, 93 CreateChannelFactory(GetChannelName(test_client_name_),
93 listener, 94 ipc_task_runner.get()),
94 ipc_task_runner); 95 listener,
96 ipc_task_runner);
95 } 97 }
96 98
97 void IPCTestBase::DestroyChannelProxy() { 99 void IPCTestBase::DestroyChannelProxy() {
98 CHECK(channel_proxy_.get()); 100 CHECK(channel_proxy_.get());
99 channel_proxy_.reset(); 101 channel_proxy_.reset();
100 } 102 }
101 103
102 bool IPCTestBase::StartClient() { 104 bool IPCTestBase::StartClient() {
103 DCHECK(client_process_ == base::kNullProcessHandle); 105 DCHECK(client_process_ == base::kNullProcessHandle);
104 106
(...skipping 23 matching lines...) Expand all
128 bool rv = base::WaitForSingleProcess(client_process_, 130 bool rv = base::WaitForSingleProcess(client_process_,
129 base::TimeDelta::FromSeconds(5)); 131 base::TimeDelta::FromSeconds(5));
130 base::CloseProcessHandle(client_process_); 132 base::CloseProcessHandle(client_process_);
131 client_process_ = base::kNullProcessHandle; 133 client_process_ = base::kNullProcessHandle;
132 return rv; 134 return rv;
133 } 135 }
134 136
135 scoped_refptr<base::TaskRunner> IPCTestBase::task_runner() { 137 scoped_refptr<base::TaskRunner> IPCTestBase::task_runner() {
136 return message_loop_->message_loop_proxy(); 138 return message_loop_->message_loop_proxy();
137 } 139 }
140
141 scoped_ptr<IPC::ChannelFactory> IPCTestBase::CreateChannelFactory(
142 const IPC::ChannelHandle& handle,
143 base::TaskRunner* runner) {
144 return IPC::ChannelFactory::Create(handle, IPC::Channel::MODE_SERVER);
145 }
OLDNEW
« no previous file with comments | « ipc/ipc_test_base.h ('k') | ipc/mojo/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698