| 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/browser/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/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 14 #include "chrome/browser/importer/firefox_importer_utils.h" | 14 #include "chrome/common/importer/firefox_importer_utils.h" |
| 15 #include "ipc/ipc_channel.h" | 15 #include "ipc/ipc_channel.h" |
| 16 #include "ipc/ipc_descriptors.h" | 16 #include "ipc/ipc_descriptors.h" |
| 17 #include "ipc/ipc_listener.h" | 17 #include "ipc/ipc_listener.h" |
| 18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
| 19 #include "ipc/ipc_multiprocess_test.h" | 19 #include "ipc/ipc_multiprocess_test.h" |
| 20 #include "ipc/ipc_switches.h" | 20 #include "ipc/ipc_switches.h" |
| 21 #include "testing/multiprocess_func_list.h" | 21 #include "testing/multiprocess_func_list.h" |
| 22 | 22 |
| 23 #define IPC_MESSAGE_IMPL | 23 #define IPC_MESSAGE_IMPL |
| 24 #include "chrome/browser/importer/firefox_importer_unittest_messages_internal.h" | 24 #include "chrome/utility/importer/firefox_importer_unittest_messages_internal.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Name of IPC Channel to use for Server<-> Child Communications. | 28 // Name of IPC Channel to use for Server<-> Child Communications. |
| 29 const char kTestChannelID[] = "T1"; | 29 const char kTestChannelID[] = "T1"; |
| 30 | 30 |
| 31 // Launch the child process: | 31 // Launch the child process: |
| 32 // |nss_path| - path to the NSS directory holding the decryption libraries. | 32 // |nss_path| - path to the NSS directory holding the decryption libraries. |
| 33 // |channel| - IPC Channel to use for communication. | 33 // |channel| - IPC Channel to use for communication. |
| 34 // |handle| - On return, the process handle to use to communicate with the | 34 // |handle| - On return, the process handle to use to communicate with the |
| 35 // child. | 35 // child. |
| 36 bool LaunchNSSDecrypterChildProcess(const base::FilePath& nss_path, | 36 bool LaunchNSSDecrypterChildProcess(const base::FilePath& nss_path, |
| 37 IPC::Channel* channel, base::ProcessHandle* handle) { | 37 IPC::Channel* channel, base::ProcessHandle* handle) { |
| 38 CommandLine cl(*CommandLine::ForCurrentProcess()); | 38 CommandLine cl(*CommandLine::ForCurrentProcess()); |
| 39 cl.AppendSwitchASCII(switches::kTestChildProcess, "NSSDecrypterChildProcess"); | 39 cl.AppendSwitchASCII(switches::kTestChildProcess, "NSSDecrypterChildProcess"); |
| 40 | 40 |
| 41 // Set env variable needed for FF encryption libs to load. | 41 // Set env variable needed for FF encryption libs to load. |
| 42 // See "chrome/browser/importer/nss_decryptor_mac.mm" for an explanation of | 42 // See "chrome/utility/importer/nss_decryptor_mac.mm" for an explanation of |
| 43 // why we need this. | 43 // why we need this. |
| 44 base::EnvironmentVector env; | 44 base::EnvironmentVector env; |
| 45 std::pair<std::string, std::string> dyld_override; | 45 std::pair<std::string, std::string> dyld_override; |
| 46 dyld_override.first = "DYLD_FALLBACK_LIBRARY_PATH"; | 46 dyld_override.first = "DYLD_FALLBACK_LIBRARY_PATH"; |
| 47 dyld_override.second = nss_path.value(); | 47 dyld_override.second = nss_path.value(); |
| 48 env.push_back(dyld_override); | 48 env.push_back(dyld_override); |
| 49 | 49 |
| 50 int ipcfd = channel->TakeClientFileDescriptor(); | 50 int ipcfd = channel->TakeClientFileDescriptor(); |
| 51 if (ipcfd == -1) | 51 if (ipcfd == -1) |
| 52 return false; | 52 return false; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); | 272 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); |
| 273 CHECK(channel.Connect()); | 273 CHECK(channel.Connect()); |
| 274 listener.SetSender(&channel); | 274 listener.SetSender(&channel); |
| 275 | 275 |
| 276 // run message loop | 276 // run message loop |
| 277 base::MessageLoop::current()->Run(); | 277 base::MessageLoop::current()->Run(); |
| 278 | 278 |
| 279 return 0; | 279 return 0; |
| 280 } | 280 } |
| OLD | NEW |