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

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

Issue 1148383003: Only support seeking file streams from the beginning of the file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more instance where files need to be tagged as async. Created 5 years, 7 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
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/files/file.h" 6 #include "base/files/file.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_file.h" 9 #include "base/files/scoped_file.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 base::FilePath temp_output_file = temp_dir_.path().AppendASCII("output"); 198 base::FilePath temp_output_file = temp_dir_.path().AppendASCII("output");
199 199
200 base::File read_file; 200 base::File read_file;
201 #if defined(OS_WIN) 201 #if defined(OS_WIN)
202 base::string16 pipe_name = base::StringPrintf( 202 base::string16 pipe_name = base::StringPrintf(
203 L"\\\\.\\pipe\\chrome.nativeMessaging.out.%llx", base::RandUint64()); 203 L"\\\\.\\pipe\\chrome.nativeMessaging.out.%llx", base::RandUint64());
204 base::File write_handle( 204 base::File write_handle(
205 CreateNamedPipeW(pipe_name.c_str(), 205 CreateNamedPipeW(pipe_name.c_str(),
206 PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED | 206 PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED |
207 FILE_FLAG_FIRST_PIPE_INSTANCE, 207 FILE_FLAG_FIRST_PIPE_INSTANCE,
208 PIPE_TYPE_BYTE, 1, 0, 0, 5000, NULL)); 208 PIPE_TYPE_BYTE, 1, 0, 0, 5000, NULL),
209 true);
209 ASSERT_TRUE(write_handle.IsValid()); 210 ASSERT_TRUE(write_handle.IsValid());
210 base::File read_handle( 211 base::File read_handle(
211 CreateFileW(pipe_name.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, 212 CreateFileW(pipe_name.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING,
212 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL)); 213 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL),
214 true);
213 ASSERT_TRUE(read_handle.IsValid()); 215 ASSERT_TRUE(read_handle.IsValid());
214 216
215 read_file = read_handle.Pass(); 217 read_file = read_handle.Pass();
216 #else // defined(OS_WIN) 218 #else // defined(OS_WIN)
217 base::PlatformFile pipe_handles[2]; 219 base::PlatformFile pipe_handles[2];
218 ASSERT_EQ(0, pipe(pipe_handles)); 220 ASSERT_EQ(0, pipe(pipe_handles));
219 read_file = base::File(pipe_handles[0]); 221 read_file = base::File(pipe_handles[0]);
220 base::File write_file(pipe_handles[1]); 222 base::File write_file(pipe_handles[1]);
221 #endif // !defined(OS_WIN) 223 #endif // !defined(OS_WIN)
222 224
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 native_message_host_->Start(this); 327 native_message_host_->Start(this);
326 ASSERT_TRUE(native_message_host_.get()); 328 ASSERT_TRUE(native_message_host_.get());
327 run_loop_.reset(new base::RunLoop()); 329 run_loop_.reset(new base::RunLoop());
328 run_loop_->Run(); 330 run_loop_->Run();
329 331
330 // The host should fail to start. 332 // The host should fail to start.
331 ASSERT_TRUE(channel_closed_); 333 ASSERT_TRUE(channel_closed_);
332 } 334 }
333 335
334 } // namespace extensions 336 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698