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 // This file defines MockFileStream, a test class for FileStream. | 5 // This file defines MockFileStream, a test class for FileStream. |
6 | 6 |
7 #ifndef NET_BASE_MOCK_FILE_STREAM_H_ | 7 #ifndef NET_BASE_MOCK_FILE_STREAM_H_ |
8 #define NET_BASE_MOCK_FILE_STREAM_H_ | 8 #define NET_BASE_MOCK_FILE_STREAM_H_ |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 class MockFileStream : public net::FileStream { | 23 class MockFileStream : public net::FileStream { |
24 public: | 24 public: |
25 explicit MockFileStream(const scoped_refptr<base::TaskRunner>& task_runner); | 25 explicit MockFileStream(const scoped_refptr<base::TaskRunner>& task_runner); |
26 MockFileStream(base::File file, | 26 MockFileStream(base::File file, |
27 const scoped_refptr<base::TaskRunner>& task_runner); | 27 const scoped_refptr<base::TaskRunner>& task_runner); |
28 virtual ~MockFileStream(); | 28 virtual ~MockFileStream(); |
29 | 29 |
30 // FileStream methods. | 30 // FileStream methods. |
31 virtual int Seek(base::File::Whence whence, int64 offset, | 31 virtual int Seek(base::File::Whence whence, int64 offset, |
32 const Int64CompletionCallback& callback) OVERRIDE; | 32 const Int64CompletionCallback& callback) override; |
33 virtual int Read(IOBuffer* buf, | 33 virtual int Read(IOBuffer* buf, |
34 int buf_len, | 34 int buf_len, |
35 const CompletionCallback& callback) OVERRIDE; | 35 const CompletionCallback& callback) override; |
36 virtual int Write(IOBuffer* buf, | 36 virtual int Write(IOBuffer* buf, |
37 int buf_len, | 37 int buf_len, |
38 const CompletionCallback& callback) OVERRIDE; | 38 const CompletionCallback& callback) override; |
39 virtual int Flush(const CompletionCallback& callback) OVERRIDE; | 39 virtual int Flush(const CompletionCallback& callback) override; |
40 | 40 |
41 void set_forced_error_async(int error) { | 41 void set_forced_error_async(int error) { |
42 forced_error_ = error; | 42 forced_error_ = error; |
43 async_error_ = true; | 43 async_error_ = true; |
44 } | 44 } |
45 void set_forced_error(int error) { | 45 void set_forced_error(int error) { |
46 forced_error_ = error; | 46 forced_error_ = error; |
47 async_error_ = false; | 47 async_error_ = false; |
48 } | 48 } |
49 void clear_forced_error() { | 49 void clear_forced_error() { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 base::FilePath path_; | 98 base::FilePath path_; |
99 | 99 |
100 base::WeakPtrFactory<MockFileStream> weak_factory_; | 100 base::WeakPtrFactory<MockFileStream> weak_factory_; |
101 }; | 101 }; |
102 | 102 |
103 } // namespace testing | 103 } // namespace testing |
104 | 104 |
105 } // namespace net | 105 } // namespace net |
106 | 106 |
107 #endif // NET_BASE_MOCK_FILE_STREAM_H_ | 107 #endif // NET_BASE_MOCK_FILE_STREAM_H_ |
OLD | NEW |