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/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/files/scoped_file.h" |
12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
13 #include "base/posix/global_descriptors.h" | 14 #include "base/posix/global_descriptors.h" |
14 #include "base/process/kill.h" | 15 #include "base/process/kill.h" |
15 #include "base/process/launch.h" | 16 #include "base/process/launch.h" |
16 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
17 #include "chrome/common/importer/firefox_importer_utils.h" | 18 #include "chrome/common/importer/firefox_importer_utils.h" |
18 #include "ipc/ipc_channel.h" | 19 #include "ipc/ipc_channel.h" |
19 #include "ipc/ipc_descriptors.h" | 20 #include "ipc/ipc_descriptors.h" |
20 #include "ipc/ipc_listener.h" | 21 #include "ipc/ipc_listener.h" |
21 #include "ipc/ipc_message.h" | 22 #include "ipc/ipc_message.h" |
(...skipping 18 matching lines...) Expand all Loading... |
40 IPC::Channel* channel, base::ProcessHandle* handle) { | 41 IPC::Channel* channel, base::ProcessHandle* handle) { |
41 CommandLine cl(*CommandLine::ForCurrentProcess()); | 42 CommandLine cl(*CommandLine::ForCurrentProcess()); |
42 cl.AppendSwitchASCII(switches::kTestChildProcess, "NSSDecrypterChildProcess"); | 43 cl.AppendSwitchASCII(switches::kTestChildProcess, "NSSDecrypterChildProcess"); |
43 | 44 |
44 // Set env variable needed for FF encryption libs to load. | 45 // Set env variable needed for FF encryption libs to load. |
45 // See "chrome/utility/importer/nss_decryptor_mac.mm" for an explanation of | 46 // See "chrome/utility/importer/nss_decryptor_mac.mm" for an explanation of |
46 // why we need this. | 47 // why we need this. |
47 base::LaunchOptions options; | 48 base::LaunchOptions options; |
48 options.environ["DYLD_FALLBACK_LIBRARY_PATH"] = nss_path.value(); | 49 options.environ["DYLD_FALLBACK_LIBRARY_PATH"] = nss_path.value(); |
49 | 50 |
50 int ipcfd = channel->TakeClientFileDescriptor(); | 51 base::ScopedFD ipcfd(channel->TakeClientFileDescriptor()); |
51 if (ipcfd == -1) | 52 if (!ipcfd.is_valid()) |
52 return false; | 53 return false; |
53 | 54 |
54 file_util::ScopedFD client_file_descriptor_closer(&ipcfd); | |
55 base::FileHandleMappingVector fds_to_map; | 55 base::FileHandleMappingVector fds_to_map; |
56 fds_to_map.push_back(std::pair<int,int>(ipcfd, | 56 fds_to_map.push_back(std::pair<int,int>(ipcfd.get(), |
57 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); | 57 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); |
58 | 58 |
59 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch( | 59 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch( |
60 switches::kDebugChildren); | 60 switches::kDebugChildren); |
61 options.fds_to_remap = &fds_to_map; | 61 options.fds_to_remap = &fds_to_map; |
62 options.wait = debug_on_start; | 62 options.wait = debug_on_start; |
63 return base::LaunchProcess(cl.argv(), options, handle); | 63 return base::LaunchProcess(cl.argv(), options, handle); |
64 } | 64 } |
65 | 65 |
66 } // namespace | 66 } // namespace |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 270 |
271 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); | 271 IPC::Channel channel(kTestChannelID, IPC::Channel::MODE_CLIENT, &listener); |
272 CHECK(channel.Connect()); | 272 CHECK(channel.Connect()); |
273 listener.SetSender(&channel); | 273 listener.SetSender(&channel); |
274 | 274 |
275 // run message loop | 275 // run message loop |
276 base::MessageLoop::current()->Run(); | 276 base::MessageLoop::current()->Run(); |
277 | 277 |
278 return 0; | 278 return 0; |
279 } | 279 } |
OLD | NEW |