Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Side by Side Diff: net/base/mock_file_stream.h

Issue 9402014: net: FileStream::Read/Write() to take IOBuffer* instead of char* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix redirect_to_file_resource_handler.cc Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/file_stream_win.cc ('k') | net/base/mock_file_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class IOBuffer;
20
19 namespace testing { 21 namespace testing {
20 22
21 class MockFileStream : public net::FileStream { 23 class MockFileStream : public net::FileStream {
22 public: 24 public:
23 MockFileStream(net::NetLog* net_log) 25 MockFileStream(net::NetLog* net_log)
24 : net::FileStream(net_log), forced_error_(net::OK) {} 26 : net::FileStream(net_log), forced_error_(net::OK) {}
25 27
26 MockFileStream(base::PlatformFile file, int flags, net::NetLog* net_log) 28 MockFileStream(base::PlatformFile file, int flags, net::NetLog* net_log)
27 : net::FileStream(file, flags, net_log), forced_error_(net::OK) {} 29 : net::FileStream(file, flags, net_log), forced_error_(net::OK) {}
28 30
29 // FileStream methods. 31 // FileStream methods.
30 virtual int OpenSync(const FilePath& path, int open_flags) OVERRIDE; 32 virtual int OpenSync(const FilePath& path, int open_flags) OVERRIDE;
31 virtual int64 Seek(net::Whence whence, int64 offset) OVERRIDE; 33 virtual int64 Seek(net::Whence whence, int64 offset) OVERRIDE;
32 virtual int64 Available() OVERRIDE; 34 virtual int64 Available() OVERRIDE;
33 virtual int Read(char* buf, 35 virtual int Read(IOBuffer* buf,
34 int buf_len, 36 int buf_len,
35 const CompletionCallback& callback) OVERRIDE; 37 const CompletionCallback& callback) OVERRIDE;
36 virtual int ReadSync(char* buf, int buf_len) OVERRIDE; 38 virtual int ReadSync(char* buf, int buf_len) OVERRIDE;
37 virtual int ReadUntilComplete(char *buf, int buf_len) OVERRIDE; 39 virtual int ReadUntilComplete(char *buf, int buf_len) OVERRIDE;
38 virtual int Write(const char* buf, 40 virtual int Write(IOBuffer* buf,
39 int buf_len, 41 int buf_len,
40 const CompletionCallback& callback) OVERRIDE; 42 const CompletionCallback& callback) OVERRIDE;
41 virtual int WriteSync(const char* buf, int buf_len) OVERRIDE; 43 virtual int WriteSync(const char* buf, int buf_len) OVERRIDE;
42 virtual int64 Truncate(int64 bytes) OVERRIDE; 44 virtual int64 Truncate(int64 bytes) OVERRIDE;
43 virtual int Flush() OVERRIDE; 45 virtual int Flush() OVERRIDE;
44 46
45 void set_forced_error(int error) { forced_error_ = error; } 47 void set_forced_error(int error) { forced_error_ = error; }
46 void clear_forced_error() { forced_error_ = net::OK; } 48 void clear_forced_error() { forced_error_ = net::OK; }
47 int forced_error() const { return forced_error_; } 49 int forced_error() const { return forced_error_; }
48 const FilePath& get_path() const { return path_; } 50 const FilePath& get_path() const { return path_; }
(...skipping 21 matching lines...) Expand all
70 72
71 int forced_error_; 73 int forced_error_;
72 FilePath path_; 74 FilePath path_;
73 }; 75 };
74 76
75 } // namespace testing 77 } // namespace testing
76 78
77 } // namespace net 79 } // namespace net
78 80
79 #endif // NET_BASE_MOCK_FILE_STREAM_H_ 81 #endif // NET_BASE_MOCK_FILE_STREAM_H_
OLDNEW
« no previous file with comments | « net/base/file_stream_win.cc ('k') | net/base/mock_file_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698