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

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: 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 "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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 15 matching lines...) Expand all
26 : FileStream(file.Pass(), task_runner), 26 : FileStream(file.Pass(), task_runner),
27 forced_error_(OK), 27 forced_error_(OK),
28 async_error_(false), 28 async_error_(false),
29 throttled_(false), 29 throttled_(false),
30 weak_factory_(this) { 30 weak_factory_(this) {
31 } 31 }
32 32
33 MockFileStream::~MockFileStream() { 33 MockFileStream::~MockFileStream() {
34 } 34 }
35 35
36 int MockFileStream::Seek(base::File::Whence whence, int64 offset, 36 int MockFileStream::Seek(int64 offset,
37 const Int64CompletionCallback& callback) { 37 const Int64CompletionCallback& callback) {
38 Int64CompletionCallback wrapped_callback = 38 Int64CompletionCallback wrapped_callback =
39 base::Bind(&MockFileStream::DoCallback64, 39 base::Bind(&MockFileStream::DoCallback64,
40 weak_factory_.GetWeakPtr(), callback); 40 weak_factory_.GetWeakPtr(), callback);
41 if (forced_error_ == OK) 41 if (forced_error_ == OK)
42 return FileStream::Seek(whence, offset, wrapped_callback); 42 return FileStream::Seek(offset, wrapped_callback);
43 return ErrorCallback64(wrapped_callback); 43 return ErrorCallback64(wrapped_callback);
44 } 44 }
45 45
46 int MockFileStream::Read(IOBuffer* buf, 46 int MockFileStream::Read(IOBuffer* buf,
47 int buf_len, 47 int buf_len,
48 const CompletionCallback& callback) { 48 const CompletionCallback& callback) {
49 CompletionCallback wrapped_callback = base::Bind(&MockFileStream::DoCallback, 49 CompletionCallback wrapped_callback = base::Bind(&MockFileStream::DoCallback,
50 weak_factory_.GetWeakPtr(), 50 weak_factory_.GetWeakPtr(),
51 callback); 51 callback);
52 if (forced_error_ == OK) 52 if (forced_error_ == OK)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return ERR_IO_PENDING; 132 return ERR_IO_PENDING;
133 } 133 }
134 int64 ret = forced_error_; 134 int64 ret = forced_error_;
135 clear_forced_error(); 135 clear_forced_error();
136 return ret; 136 return ret;
137 } 137 }
138 138
139 } // namespace testing 139 } // namespace testing
140 140
141 } // namespace net 141 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698