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 "net/base/mock_file_stream.h" | 5 #include "net/base/mock_file_stream.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/location.h" | 10 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
11 | 13 |
12 namespace net { | 14 namespace net { |
13 | 15 |
14 namespace testing { | 16 namespace testing { |
15 | 17 |
16 MockFileStream::MockFileStream( | 18 MockFileStream::MockFileStream( |
17 const scoped_refptr<base::TaskRunner>& task_runner) | 19 const scoped_refptr<base::TaskRunner>& task_runner) |
18 : FileStream(task_runner), | 20 : FileStream(task_runner), |
19 forced_error_(OK), | 21 forced_error_(OK), |
20 async_error_(false), | 22 async_error_(false), |
21 throttled_(false), | 23 throttled_(false), |
22 weak_factory_(this) { | 24 weak_factory_(this) { |
23 } | 25 } |
24 | 26 |
25 MockFileStream::MockFileStream( | 27 MockFileStream::MockFileStream( |
26 base::File file, | 28 base::File file, |
27 const scoped_refptr<base::TaskRunner>& task_runner) | 29 const scoped_refptr<base::TaskRunner>& task_runner) |
28 : FileStream(file.Pass(), task_runner), | 30 : FileStream(std::move(file), task_runner), |
29 forced_error_(OK), | 31 forced_error_(OK), |
30 async_error_(false), | 32 async_error_(false), |
31 throttled_(false), | 33 throttled_(false), |
32 weak_factory_(this) { | 34 weak_factory_(this) {} |
33 } | |
34 | 35 |
35 MockFileStream::~MockFileStream() { | 36 MockFileStream::~MockFileStream() { |
36 } | 37 } |
37 | 38 |
38 int MockFileStream::Seek(int64_t offset, | 39 int MockFileStream::Seek(int64_t offset, |
39 const Int64CompletionCallback& callback) { | 40 const Int64CompletionCallback& callback) { |
40 Int64CompletionCallback wrapped_callback = | 41 Int64CompletionCallback wrapped_callback = |
41 base::Bind(&MockFileStream::DoCallback64, | 42 base::Bind(&MockFileStream::DoCallback64, |
42 weak_factory_.GetWeakPtr(), callback); | 43 weak_factory_.GetWeakPtr(), callback); |
43 if (forced_error_ == OK) | 44 if (forced_error_ == OK) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return ERR_IO_PENDING; | 136 return ERR_IO_PENDING; |
136 } | 137 } |
137 int64_t ret = forced_error_; | 138 int64_t ret = forced_error_; |
138 clear_forced_error(); | 139 clear_forced_error(); |
139 return ret; | 140 return ret; |
140 } | 141 } |
141 | 142 |
142 } // namespace testing | 143 } // namespace testing |
143 | 144 |
144 } // namespace net | 145 } // namespace net |
OLD | NEW |