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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/scoped_file.h" | |
9 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
10 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
14 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
15 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
16 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
17 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
18 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 ASSERT_TRUE(write_handle); | 207 ASSERT_TRUE(write_handle); |
209 base::win::ScopedHandle read_handle( | 208 base::win::ScopedHandle read_handle( |
210 CreateFileW(pipe_name.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, | 209 CreateFileW(pipe_name.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, |
211 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL)); | 210 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL)); |
212 ASSERT_TRUE(read_handle); | 211 ASSERT_TRUE(read_handle); |
213 | 212 |
214 read_file = read_handle.Get(); | 213 read_file = read_handle.Get(); |
215 #else // defined(OS_WIN) | 214 #else // defined(OS_WIN) |
216 base::PlatformFile pipe_handles[2]; | 215 base::PlatformFile pipe_handles[2]; |
217 ASSERT_EQ(0, pipe(pipe_handles)); | 216 ASSERT_EQ(0, pipe(pipe_handles)); |
218 base::ScopedFD read_fd(pipe_handles[0]); | 217 file_util::ScopedFD read_fd(pipe_handles); |
219 base::ScopedFD write_fd(pipe_handles[1]); | 218 file_util::ScopedFD write_fd(pipe_handles + 1); |
220 | 219 |
221 read_file = pipe_handles[0]; | 220 read_file = pipe_handles[0]; |
222 #endif // !defined(OS_WIN) | 221 #endif // !defined(OS_WIN) |
223 | 222 |
224 scoped_ptr<NativeProcessLauncher> launcher = | 223 scoped_ptr<NativeProcessLauncher> launcher = |
225 FakeLauncher::CreateWithPipeInput(read_file, temp_output_file).Pass(); | 224 FakeLauncher::CreateWithPipeInput(read_file, temp_output_file).Pass(); |
226 native_message_process_host_ = NativeMessageProcessHost::CreateWithLauncher( | 225 native_message_process_host_ = NativeMessageProcessHost::CreateWithLauncher( |
227 AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, "empty_app.py", | 226 AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, "empty_app.py", |
228 0, launcher.Pass()); | 227 0, launcher.Pass()); |
229 ASSERT_TRUE(native_message_process_host_.get()); | 228 ASSERT_TRUE(native_message_process_host_.get()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 ScopedTestNativeMessagingHost::kHostName, 0, false); | 308 ScopedTestNativeMessagingHost::kHostName, 0, false); |
310 ASSERT_TRUE(native_message_process_host_.get()); | 309 ASSERT_TRUE(native_message_process_host_.get()); |
311 run_loop_.reset(new base::RunLoop()); | 310 run_loop_.reset(new base::RunLoop()); |
312 run_loop_->Run(); | 311 run_loop_->Run(); |
313 | 312 |
314 // The host should fail to start. | 313 // The host should fail to start. |
315 ASSERT_TRUE(channel_closed_); | 314 ASSERT_TRUE(channel_closed_); |
316 } | 315 } |
317 | 316 |
318 } // namespace extensions | 317 } // namespace extensions |
OLD | NEW |