Chromium Code Reviews| 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 "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 21 matching lines...) Expand all Loading... | |
| 32 void IPCTestBase::SetUp() { | 32 void IPCTestBase::SetUp() { |
| 33 MultiProcessTest::SetUp(); | 33 MultiProcessTest::SetUp(); |
| 34 | 34 |
| 35 // Construct a fresh IO Message loop for the duration of each test. | 35 // Construct a fresh IO Message loop for the duration of each test. |
| 36 DCHECK(!message_loop_.get()); | 36 DCHECK(!message_loop_.get()); |
| 37 message_loop_.reset(new base::MessageLoopForIO()); | 37 message_loop_.reset(new base::MessageLoopForIO()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void IPCTestBase::TearDown() { | 40 void IPCTestBase::TearDown() { |
| 41 DCHECK(message_loop_.get()); | 41 DCHECK(message_loop_.get()); |
| 42 message_loop_.reset(); | 42 message_loop_ = CreateMessageLoop().Pass(); |
| 43 MultiProcessTest::TearDown(); | 43 MultiProcessTest::TearDown(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 scoped_ptr<base::MessageLoop> IPCTestBase::CreateMessageLoop() { | |
| 47 return make_scoped_ptr<base::MessageLoop>(new base::MessageLoopForIO()); | |
|
viettrungluu
2014/08/27 16:47:18
Nit: If you have to give the template parameter, t
Hajime Morrita
2014/08/27 17:47:43
Done.
| |
| 48 } | |
| 49 | |
| 46 void IPCTestBase::Init(const std::string& test_client_name) { | 50 void IPCTestBase::Init(const std::string& test_client_name) { |
| 47 DCHECK(!test_client_name.empty()); | 51 DCHECK(!test_client_name.empty()); |
| 48 DCHECK(test_client_name_.empty()); | 52 DCHECK(test_client_name_.empty()); |
| 49 test_client_name_ = test_client_name; | 53 test_client_name_ = test_client_name; |
| 50 } | 54 } |
| 51 | 55 |
| 52 void IPCTestBase::CreateChannel(IPC::Listener* listener) { | 56 void IPCTestBase::CreateChannel(IPC::Listener* listener) { |
| 53 return CreateChannelFromChannelHandle(GetChannelName(test_client_name_), | 57 return CreateChannelFromChannelHandle(GetChannelName(test_client_name_), |
| 54 listener); | 58 listener); |
| 55 } | 59 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 bool IPCTestBase::WaitForClientShutdown() { | 127 bool IPCTestBase::WaitForClientShutdown() { |
| 124 DCHECK(client_process_ != base::kNullProcessHandle); | 128 DCHECK(client_process_ != base::kNullProcessHandle); |
| 125 | 129 |
| 126 bool rv = base::WaitForSingleProcess(client_process_, | 130 bool rv = base::WaitForSingleProcess(client_process_, |
| 127 base::TimeDelta::FromSeconds(5)); | 131 base::TimeDelta::FromSeconds(5)); |
| 128 base::CloseProcessHandle(client_process_); | 132 base::CloseProcessHandle(client_process_); |
| 129 client_process_ = base::kNullProcessHandle; | 133 client_process_ = base::kNullProcessHandle; |
| 130 return rv; | 134 return rv; |
| 131 } | 135 } |
| 132 | 136 |
| 133 scoped_refptr<base::TaskRunner> IPCTestBase::io_thread_task_runner() { | 137 scoped_refptr<base::TaskRunner> IPCTestBase::task_runner() { |
| 134 return message_loop_->message_loop_proxy(); | 138 return message_loop_->message_loop_proxy(); |
| 135 } | 139 } |
| OLD | NEW |