| 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 #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(net::NetLog* net_log) | 23 MockFileStream(net::NetLog* net_log) |
| 24 : net::FileStream(net_log), forced_error_(net::OK) {} | 24 : net::FileStream(net_log), forced_error_(net::OK) {} |
| 25 | 25 |
| 26 MockFileStream(base::PlatformFile file, int flags, net::NetLog* net_log) | 26 MockFileStream(base::PlatformFile file, int flags, net::NetLog* net_log) |
| 27 : net::FileStream(file, flags, net_log), forced_error_(net::OK) {} | 27 : net::FileStream(file, flags, net_log), forced_error_(net::OK) {} |
| 28 | 28 |
| 29 // FileStream methods. | 29 // FileStream methods. |
| 30 virtual int Open(const FilePath& path, int open_flags) OVERRIDE; | 30 virtual int OpenSync(const FilePath& path, int open_flags) OVERRIDE; |
| 31 virtual int64 Seek(net::Whence whence, int64 offset) OVERRIDE; | 31 virtual int64 Seek(net::Whence whence, int64 offset) OVERRIDE; |
| 32 virtual int64 Available() OVERRIDE; | 32 virtual int64 Available() OVERRIDE; |
| 33 virtual int Read(char* buf, | 33 virtual int Read(char* buf, |
| 34 int buf_len, | 34 int buf_len, |
| 35 const CompletionCallback& callback) OVERRIDE; | 35 const CompletionCallback& callback) OVERRIDE; |
| 36 virtual int ReadUntilComplete(char *buf, int buf_len) OVERRIDE; | 36 virtual int ReadUntilComplete(char *buf, int buf_len) OVERRIDE; |
| 37 virtual int Write(const char* buf, | 37 virtual int Write(const char* buf, |
| 38 int buf_len, | 38 int buf_len, |
| 39 const CompletionCallback& callback) OVERRIDE; | 39 const CompletionCallback& callback) OVERRIDE; |
| 40 virtual int64 Truncate(int64 bytes) OVERRIDE; | 40 virtual int64 Truncate(int64 bytes) OVERRIDE; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 | 68 |
| 69 int forced_error_; | 69 int forced_error_; |
| 70 FilePath path_; | 70 FilePath path_; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace testing | 73 } // namespace testing |
| 74 | 74 |
| 75 } // namespace net | 75 } // namespace net |
| 76 | 76 |
| 77 #endif // NET_BASE_MOCK_FILE_STREAM_H_ | 77 #endif // NET_BASE_MOCK_FILE_STREAM_H_ |
| OLD | NEW |