OLD | NEW |
1 // Copyright (c) 2011 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/browser/importer/firefox_importer_unittest_utils.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
(...skipping 20 matching lines...) Expand all Loading... |
32 // |handle| - On return, the process handle to use to communicate with the | 32 // |handle| - On return, the process handle to use to communicate with the |
33 // child. | 33 // child. |
34 bool LaunchNSSDecrypterChildProcess(const FilePath& nss_path, | 34 bool LaunchNSSDecrypterChildProcess(const FilePath& nss_path, |
35 IPC::Channel* channel, base::ProcessHandle* handle) { | 35 IPC::Channel* channel, base::ProcessHandle* handle) { |
36 CommandLine cl(*CommandLine::ForCurrentProcess()); | 36 CommandLine cl(*CommandLine::ForCurrentProcess()); |
37 cl.AppendSwitchASCII(switches::kTestChildProcess, "NSSDecrypterChildProcess"); | 37 cl.AppendSwitchASCII(switches::kTestChildProcess, "NSSDecrypterChildProcess"); |
38 | 38 |
39 // Set env variable needed for FF encryption libs to load. | 39 // Set env variable needed for FF encryption libs to load. |
40 // See "chrome/browser/importer/nss_decryptor_mac.mm" for an explanation of | 40 // See "chrome/browser/importer/nss_decryptor_mac.mm" for an explanation of |
41 // why we need this. | 41 // why we need this. |
42 base::environment_vector env; | 42 base::EnvironmentVector env; |
43 std::pair<std::string, std::string> dyld_override; | 43 std::pair<std::string, std::string> dyld_override; |
44 dyld_override.first = "DYLD_FALLBACK_LIBRARY_PATH"; | 44 dyld_override.first = "DYLD_FALLBACK_LIBRARY_PATH"; |
45 dyld_override.second = nss_path.value(); | 45 dyld_override.second = nss_path.value(); |
46 env.push_back(dyld_override); | 46 env.push_back(dyld_override); |
47 | 47 |
48 int ipcfd = channel->TakeClientFileDescriptor(); | 48 int ipcfd = channel->TakeClientFileDescriptor(); |
49 if (ipcfd == -1) | 49 if (ipcfd == -1) |
50 return false; | 50 return false; |
51 | 51 |
52 file_util::ScopedFD client_file_descriptor_closer(&ipcfd); | 52 file_util::ScopedFD client_file_descriptor_closer(&ipcfd); |
53 base::file_handle_mapping_vector fds_to_map; | 53 base::FileHandleMappingVector fds_to_map; |
54 fds_to_map.push_back(std::pair<int,int>(ipcfd, kPrimaryIPCChannel + 3)); | 54 fds_to_map.push_back(std::pair<int,int>(ipcfd, kPrimaryIPCChannel + 3)); |
55 | 55 |
56 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch( | 56 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch( |
57 switches::kDebugChildren); | 57 switches::kDebugChildren); |
58 base::LaunchOptions options; | 58 base::LaunchOptions options; |
59 options.environ = &env; | 59 options.environ = &env; |
60 options.fds_to_remap = &fds_to_map; | 60 options.fds_to_remap = &fds_to_map; |
61 options.wait = debug_on_start; | 61 options.wait = debug_on_start; |
62 return base::LaunchProcess(cl.argv(), options, handle); | 62 return base::LaunchProcess(cl.argv(), options, handle); |
63 } | 63 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); | 266 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); |
267 CHECK(channel.Connect()); | 267 CHECK(channel.Connect()); |
268 listener.SetSender(&channel); | 268 listener.SetSender(&channel); |
269 | 269 |
270 // run message loop | 270 // run message loop |
271 MessageLoop::current()->Run(); | 271 MessageLoop::current()->Run(); |
272 | 272 |
273 return 0; | 273 return 0; |
274 } | 274 } |
OLD | NEW |