Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc

Issue 191673003: Implement ScopedFD in terms of ScopedGeneric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
8 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
9 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
13 #include "base/platform_file.h" 14 #include "base/platform_file.h"
14 #include "base/rand_util.h" 15 #include "base/rand_util.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/test/test_timeouts.h" 18 #include "base/test/test_timeouts.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 ASSERT_TRUE(write_handle); 208 ASSERT_TRUE(write_handle);
208 base::win::ScopedHandle read_handle( 209 base::win::ScopedHandle read_handle(
209 CreateFileW(pipe_name.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, 210 CreateFileW(pipe_name.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING,
210 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL)); 211 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL));
211 ASSERT_TRUE(read_handle); 212 ASSERT_TRUE(read_handle);
212 213
213 read_file = read_handle.Get(); 214 read_file = read_handle.Get();
214 #else // defined(OS_WIN) 215 #else // defined(OS_WIN)
215 base::PlatformFile pipe_handles[2]; 216 base::PlatformFile pipe_handles[2];
216 ASSERT_EQ(0, pipe(pipe_handles)); 217 ASSERT_EQ(0, pipe(pipe_handles));
217 file_util::ScopedFD read_fd(pipe_handles); 218 base::ScopedFD read_fd(pipe_handles[0]);
218 file_util::ScopedFD write_fd(pipe_handles + 1); 219 base::ScopedFD write_fd(pipe_handles[1]);
219 220
220 read_file = pipe_handles[0]; 221 read_file = pipe_handles[0];
221 #endif // !defined(OS_WIN) 222 #endif // !defined(OS_WIN)
222 223
223 scoped_ptr<NativeProcessLauncher> launcher = 224 scoped_ptr<NativeProcessLauncher> launcher =
224 FakeLauncher::CreateWithPipeInput(read_file, temp_output_file).Pass(); 225 FakeLauncher::CreateWithPipeInput(read_file, temp_output_file).Pass();
225 native_message_process_host_ = NativeMessageProcessHost::CreateWithLauncher( 226 native_message_process_host_ = NativeMessageProcessHost::CreateWithLauncher(
226 AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, "empty_app.py", 227 AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, "empty_app.py",
227 0, launcher.Pass()); 228 0, launcher.Pass());
228 ASSERT_TRUE(native_message_process_host_.get()); 229 ASSERT_TRUE(native_message_process_host_.get());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 ScopedTestNativeMessagingHost::kHostName, 0, false); 309 ScopedTestNativeMessagingHost::kHostName, 0, false);
309 ASSERT_TRUE(native_message_process_host_.get()); 310 ASSERT_TRUE(native_message_process_host_.get());
310 run_loop_.reset(new base::RunLoop()); 311 run_loop_.reset(new base::RunLoop());
311 run_loop_->Run(); 312 run_loop_->Run();
312 313
313 // The host should fail to start. 314 // The host should fail to start.
314 ASSERT_TRUE(channel_closed_); 315 ASSERT_TRUE(channel_closed_);
315 } 316 }
316 317
317 } // namespace extensions 318 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698