OLD | NEW |
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 "ipc/ipc_test_base.h" |
6 | 6 |
7 #include "base/single_thread_task_runner.h" | 7 #include <utility> |
8 #include "ipc/ipc_test_base.h" | |
9 | 8 |
10 #include "base/command_line.h" | 9 #include "base/command_line.h" |
11 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
| 11 #include "base/single_thread_task_runner.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "build/build_config.h" |
14 #include "ipc/ipc_descriptors.h" | 15 #include "ipc/ipc_descriptors.h" |
15 | 16 |
16 #if defined(OS_POSIX) | 17 #if defined(OS_POSIX) |
17 #include "base/posix/global_descriptors.h" | 18 #include "base/posix/global_descriptors.h" |
18 #endif | 19 #endif |
19 | 20 |
20 // static | 21 // static |
21 std::string IPCTestBase::GetChannelName(const std::string& test_client_name) { | 22 std::string IPCTestBase::GetChannelName(const std::string& test_client_name) { |
22 DCHECK(!test_client_name.empty()); | 23 DCHECK(!test_client_name.empty()); |
23 return test_client_name + "__Channel"; | 24 return test_client_name + "__Channel"; |
(...skipping 17 matching lines...) Expand all Loading... |
41 } | 42 } |
42 | 43 |
43 void IPCTestBase::InitWithCustomMessageLoop( | 44 void IPCTestBase::InitWithCustomMessageLoop( |
44 const std::string& test_client_name, | 45 const std::string& test_client_name, |
45 scoped_ptr<base::MessageLoop> message_loop) { | 46 scoped_ptr<base::MessageLoop> message_loop) { |
46 DCHECK(!test_client_name.empty()); | 47 DCHECK(!test_client_name.empty()); |
47 DCHECK(test_client_name_.empty()); | 48 DCHECK(test_client_name_.empty()); |
48 DCHECK(!message_loop_); | 49 DCHECK(!message_loop_); |
49 | 50 |
50 test_client_name_ = test_client_name; | 51 test_client_name_ = test_client_name; |
51 message_loop_ = message_loop.Pass(); | 52 message_loop_ = std::move(message_loop); |
52 } | 53 } |
53 | 54 |
54 void IPCTestBase::CreateChannel(IPC::Listener* listener) { | 55 void IPCTestBase::CreateChannel(IPC::Listener* listener) { |
55 CreateChannelFromChannelHandle(GetTestChannelHandle(), listener); | 56 CreateChannelFromChannelHandle(GetTestChannelHandle(), listener); |
56 } | 57 } |
57 | 58 |
58 bool IPCTestBase::ConnectChannel() { | 59 bool IPCTestBase::ConnectChannel() { |
59 CHECK(channel_.get()); | 60 CHECK(channel_.get()); |
60 return channel_->Connect(); | 61 return channel_->Connect(); |
61 } | 62 } |
62 | 63 |
63 scoped_ptr<IPC::Channel> IPCTestBase::ReleaseChannel() { | 64 scoped_ptr<IPC::Channel> IPCTestBase::ReleaseChannel() { |
64 return channel_.Pass(); | 65 return std::move(channel_); |
65 } | 66 } |
66 | 67 |
67 void IPCTestBase::SetChannel(scoped_ptr<IPC::Channel> channel) { | 68 void IPCTestBase::SetChannel(scoped_ptr<IPC::Channel> channel) { |
68 channel_ = channel.Pass(); | 69 channel_ = std::move(channel); |
69 } | 70 } |
70 | 71 |
71 | 72 |
72 void IPCTestBase::DestroyChannel() { | 73 void IPCTestBase::DestroyChannel() { |
73 DCHECK(channel_.get()); | 74 DCHECK(channel_.get()); |
74 channel_.reset(); | 75 channel_.reset(); |
75 } | 76 } |
76 | 77 |
77 void IPCTestBase::CreateChannelFromChannelHandle( | 78 void IPCTestBase::CreateChannelFromChannelHandle( |
78 const IPC::ChannelHandle& channel_handle, | 79 const IPC::ChannelHandle& channel_handle, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 156 |
156 scoped_refptr<base::SequencedTaskRunner> IPCTestBase::task_runner() { | 157 scoped_refptr<base::SequencedTaskRunner> IPCTestBase::task_runner() { |
157 return message_loop_->task_runner(); | 158 return message_loop_->task_runner(); |
158 } | 159 } |
159 | 160 |
160 scoped_ptr<IPC::ChannelFactory> IPCTestBase::CreateChannelFactory( | 161 scoped_ptr<IPC::ChannelFactory> IPCTestBase::CreateChannelFactory( |
161 const IPC::ChannelHandle& handle, | 162 const IPC::ChannelHandle& handle, |
162 base::SequencedTaskRunner* runner) { | 163 base::SequencedTaskRunner* runner) { |
163 return IPC::ChannelFactory::Create(handle, IPC::Channel::MODE_SERVER); | 164 return IPC::ChannelFactory::Create(handle, IPC::Channel::MODE_SERVER); |
164 } | 165 } |
OLD | NEW |