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

Side by Side Diff: net/base/mock_file_stream.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: Fix Win DBG build by Pass()-ing file out of CreateForAsyncHandle. Created 5 years, 6 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
« no previous file with comments | « net/base/mock_file_stream.h ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/base/mock_file_stream.h" 5 #include "net/base/mock_file_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 17 matching lines...) Expand all
28 : FileStream(file.Pass(), task_runner), 28 : FileStream(file.Pass(), task_runner),
29 forced_error_(OK), 29 forced_error_(OK),
30 async_error_(false), 30 async_error_(false),
31 throttled_(false), 31 throttled_(false),
32 weak_factory_(this) { 32 weak_factory_(this) {
33 } 33 }
34 34
35 MockFileStream::~MockFileStream() { 35 MockFileStream::~MockFileStream() {
36 } 36 }
37 37
38 int MockFileStream::Seek(base::File::Whence whence, 38 int MockFileStream::Seek(int64_t offset,
39 int64_t offset,
40 const Int64CompletionCallback& callback) { 39 const Int64CompletionCallback& callback) {
41 Int64CompletionCallback wrapped_callback = 40 Int64CompletionCallback wrapped_callback =
42 base::Bind(&MockFileStream::DoCallback64, 41 base::Bind(&MockFileStream::DoCallback64,
43 weak_factory_.GetWeakPtr(), callback); 42 weak_factory_.GetWeakPtr(), callback);
44 if (forced_error_ == OK) 43 if (forced_error_ == OK)
45 return FileStream::Seek(whence, offset, wrapped_callback); 44 return FileStream::Seek(offset, wrapped_callback);
46 return ErrorCallback64(wrapped_callback); 45 return ErrorCallback64(wrapped_callback);
47 } 46 }
48 47
49 int MockFileStream::Read(IOBuffer* buf, 48 int MockFileStream::Read(IOBuffer* buf,
50 int buf_len, 49 int buf_len,
51 const CompletionCallback& callback) { 50 const CompletionCallback& callback) {
52 CompletionCallback wrapped_callback = base::Bind(&MockFileStream::DoCallback, 51 CompletionCallback wrapped_callback = base::Bind(&MockFileStream::DoCallback,
53 weak_factory_.GetWeakPtr(), 52 weak_factory_.GetWeakPtr(),
54 callback); 53 callback);
55 if (forced_error_ == OK) 54 if (forced_error_ == OK)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return ERR_IO_PENDING; 135 return ERR_IO_PENDING;
137 } 136 }
138 int64_t ret = forced_error_; 137 int64_t ret = forced_error_;
139 clear_forced_error(); 138 clear_forced_error();
140 return ret; 139 return ret;
141 } 140 }
142 141
143 } // namespace testing 142 } // namespace testing
144 143
145 } // namespace net 144 } // namespace net
OLDNEW
« no previous file with comments | « net/base/mock_file_stream.h ('k') | net/base/upload_file_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698