| 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 "chrome/utility/importer/firefox_importer_unittest_utils.h" | 5 #include "chrome/utility/importer/firefox_importer_unittest_utils.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/files/scoped_file.h" | 12 #include "base/files/scoped_file.h" |
| 13 #include "base/location.h" |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 14 #include "base/posix/global_descriptors.h" | 15 #include "base/posix/global_descriptors.h" |
| 15 #include "base/process/kill.h" | 16 #include "base/process/kill.h" |
| 16 #include "base/process/launch.h" | 17 #include "base/process/launch.h" |
| 18 #include "base/single_thread_task_runner.h" |
| 17 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "chrome/common/importer/firefox_importer_utils.h" | 21 #include "chrome/common/importer/firefox_importer_utils.h" |
| 19 #include "ipc/ipc_channel.h" | 22 #include "ipc/ipc_channel.h" |
| 20 #include "ipc/ipc_descriptors.h" | 23 #include "ipc/ipc_descriptors.h" |
| 21 #include "ipc/ipc_listener.h" | 24 #include "ipc/ipc_listener.h" |
| 22 #include "ipc/ipc_message.h" | 25 #include "ipc/ipc_message.h" |
| 23 #include "ipc/ipc_multiprocess_test.h" | 26 #include "ipc/ipc_multiprocess_test.h" |
| 24 #include "testing/multiprocess_func_list.h" | 27 #include "testing/multiprocess_func_list.h" |
| 25 | 28 |
| 26 #define IPC_MESSAGE_IMPL | 29 #define IPC_MESSAGE_IMPL |
| 27 #include "chrome/utility/importer/firefox_importer_unittest_messages_internal.h" | 30 #include "chrome/utility/importer/firefox_importer_unittest_messages_internal.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 bool FFUnitTestDecryptorProxy::WaitForClientResponse() { | 180 bool FFUnitTestDecryptorProxy::WaitForClientResponse() { |
| 178 // What we're trying to do here is to wait for an RPC message to go over the | 181 // What we're trying to do here is to wait for an RPC message to go over the |
| 179 // wire and the client to reply. If the client does not reply by a given | 182 // wire and the client to reply. If the client does not reply by a given |
| 180 // timeout we kill the message loop. | 183 // timeout we kill the message loop. |
| 181 // The way we do this is to post a CancellableQuitMsgLoop for 3 seconds in | 184 // The way we do this is to post a CancellableQuitMsgLoop for 3 seconds in |
| 182 // the future and cancel it if an RPC message comes back earlier. | 185 // the future and cancel it if an RPC message comes back earlier. |
| 183 // This relies on the IPC listener class to quit the message loop itself when | 186 // This relies on the IPC listener class to quit the message loop itself when |
| 184 // a message comes in. | 187 // a message comes in. |
| 185 scoped_refptr<CancellableQuitMsgLoop> quit_task( | 188 scoped_refptr<CancellableQuitMsgLoop> quit_task( |
| 186 new CancellableQuitMsgLoop()); | 189 new CancellableQuitMsgLoop()); |
| 187 base::MessageLoop::current()->PostDelayedTask( | 190 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 188 FROM_HERE, | 191 FROM_HERE, base::Bind(&CancellableQuitMsgLoop::QuitNow, quit_task.get()), |
| 189 base::Bind(&CancellableQuitMsgLoop::QuitNow, quit_task.get()), | |
| 190 TestTimeouts::action_max_timeout()); | 192 TestTimeouts::action_max_timeout()); |
| 191 | 193 |
| 192 message_loop_->Run(); | 194 message_loop_->Run(); |
| 193 bool ret = !quit_task->cancelled_; | 195 bool ret = !quit_task->cancelled_; |
| 194 quit_task->cancelled_ = false; | 196 quit_task->cancelled_ = false; |
| 195 return ret; | 197 return ret; |
| 196 } | 198 } |
| 197 | 199 |
| 198 bool FFUnitTestDecryptorProxy::DecryptorInit(const base::FilePath& dll_path, | 200 bool FFUnitTestDecryptorProxy::DecryptorInit(const base::FilePath& dll_path, |
| 199 const base::FilePath& db_path) { | 201 const base::FilePath& db_path) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 std::unique_ptr<IPC::Channel> channel = | 289 std::unique_ptr<IPC::Channel> channel = |
| 288 IPC::Channel::CreateClient(kTestChannelID, &listener); | 290 IPC::Channel::CreateClient(kTestChannelID, &listener); |
| 289 CHECK(channel->Connect()); | 291 CHECK(channel->Connect()); |
| 290 listener.SetSender(channel.get()); | 292 listener.SetSender(channel.get()); |
| 291 | 293 |
| 292 // run message loop | 294 // run message loop |
| 293 base::MessageLoop::current()->Run(); | 295 base::MessageLoop::current()->Run(); |
| 294 | 296 |
| 295 return 0; | 297 return 0; |
| 296 } | 298 } |
| OLD | NEW |