[email protected] | fe57eb2 | 2012-02-09 05:59:40 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/base/mock_file_stream.h" |
| 6 | |
| 7 | namespace net { |
| 8 | |
| 9 | namespace testing { |
| 10 | |
[email protected] | fe57eb2 | 2012-02-09 05:59:40 | [diff] [blame] | 11 | int MockFileStream::OpenSync(const FilePath& path, int open_flags) { |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 12 | path_ = path; |
[email protected] | fe57eb2 | 2012-02-09 05:59:40 | [diff] [blame] | 13 | return ReturnError(FileStream::OpenSync(path, open_flags)); |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 14 | } |
| 15 | |
[email protected] | 5eb431e2 | 2011-10-12 08:51:38 | [diff] [blame] | 16 | int64 MockFileStream::Seek(Whence whence, int64 offset) { |
| 17 | return ReturnError64(FileStream::Seek(whence, offset)); |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | int64 MockFileStream::Available() { |
[email protected] | 5eb431e2 | 2011-10-12 08:51:38 | [diff] [blame] | 21 | return ReturnError64(FileStream::Available()); |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 22 | } |
| 23 | |
[email protected] | 9f49afb | 2012-02-16 09:59:20 | [diff] [blame^] | 24 | int MockFileStream::Read(IOBuffer* buf, |
[email protected] | 5eb431e2 | 2011-10-12 08:51:38 | [diff] [blame] | 25 | int buf_len, |
| 26 | const CompletionCallback& callback) { |
| 27 | return ReturnError(FileStream::Read(buf, buf_len, callback)); |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 28 | } |
| 29 | |
[email protected] | 6b230f4 | 2012-02-15 04:08:41 | [diff] [blame] | 30 | int MockFileStream::ReadSync(char* buf, int buf_len) { |
| 31 | return ReturnError(FileStream::ReadSync(buf, buf_len)); |
| 32 | } |
| 33 | |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 34 | int MockFileStream::ReadUntilComplete(char *buf, int buf_len) { |
[email protected] | 5eb431e2 | 2011-10-12 08:51:38 | [diff] [blame] | 35 | return ReturnError(FileStream::ReadUntilComplete(buf, buf_len)); |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 36 | } |
| 37 | |
[email protected] | 9f49afb | 2012-02-16 09:59:20 | [diff] [blame^] | 38 | int MockFileStream::Write(IOBuffer* buf, |
[email protected] | 5eb431e2 | 2011-10-12 08:51:38 | [diff] [blame] | 39 | int buf_len, |
| 40 | const CompletionCallback& callback) { |
| 41 | return ReturnError(FileStream::Write(buf, buf_len, callback)); |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 42 | } |
| 43 | |
[email protected] | 6b230f4 | 2012-02-15 04:08:41 | [diff] [blame] | 44 | int MockFileStream::WriteSync(const char* buf, int buf_len) { |
| 45 | return ReturnError(FileStream::WriteSync(buf, buf_len)); |
| 46 | } |
| 47 | |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 48 | int64 MockFileStream::Truncate(int64 bytes) { |
[email protected] | 5eb431e2 | 2011-10-12 08:51:38 | [diff] [blame] | 49 | return ReturnError64(FileStream::Truncate(bytes)); |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | int MockFileStream::Flush() { |
[email protected] | 5eb431e2 | 2011-10-12 08:51:38 | [diff] [blame] | 53 | return ReturnError(FileStream::Flush()); |
[email protected] | 47a881b | 2011-08-29 22:59:21 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | } // namespace testing |
| 57 | |
| 58 | } // namespace net |