OLD | NEW |
1 // Copyright (c) 2011 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 #pragma once | 9 #pragma once |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "net/base/file_stream.h" | 14 #include "net/base/file_stream.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 namespace testing { | 19 namespace testing { |
20 | 20 |
21 class MockFileStream : public net::FileStream { | 21 class MockFileStream : public net::FileStream { |
22 public: | 22 public: |
23 MockFileStream() : forced_error_(net::OK) {} | 23 MockFileStream(net::NetLog* net_log) |
| 24 : net::FileStream(net_log), forced_error_(net::OK) {} |
24 | 25 |
25 MockFileStream(base::PlatformFile file, int flags) | 26 MockFileStream(base::PlatformFile file, int flags, net::NetLog* net_log) |
26 : net::FileStream(file, flags), forced_error_(net::OK) {} | 27 : net::FileStream(file, flags, net_log), forced_error_(net::OK) {} |
27 | 28 |
28 // FileStream methods. | 29 // FileStream methods. |
29 virtual int Open(const FilePath& path, int open_flags) OVERRIDE; | 30 virtual int Open(const FilePath& path, int open_flags) OVERRIDE; |
30 virtual int64 Seek(net::Whence whence, int64 offset) OVERRIDE; | 31 virtual int64 Seek(net::Whence whence, int64 offset) OVERRIDE; |
31 virtual int64 Available() OVERRIDE; | 32 virtual int64 Available() OVERRIDE; |
32 virtual int Read(char* buf, | 33 virtual int Read(char* buf, |
33 int buf_len, | 34 int buf_len, |
34 const CompletionCallback& callback) OVERRIDE; | 35 const CompletionCallback& callback) OVERRIDE; |
35 virtual int ReadUntilComplete(char *buf, int buf_len) OVERRIDE; | 36 virtual int ReadUntilComplete(char *buf, int buf_len) OVERRIDE; |
36 virtual int Write(const char* buf, | 37 virtual int Write(const char* buf, |
(...skipping 30 matching lines...) Expand all Loading... |
67 | 68 |
68 int forced_error_; | 69 int forced_error_; |
69 FilePath path_; | 70 FilePath path_; |
70 }; | 71 }; |
71 | 72 |
72 } // namespace testing | 73 } // namespace testing |
73 | 74 |
74 } // namespace net | 75 } // namespace net |
75 | 76 |
76 #endif // NET_BASE_MOCK_FILE_STREAM_H_ | 77 #endif // NET_BASE_MOCK_FILE_STREAM_H_ |
OLD | NEW |