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

Side by Side Diff: net/base/file_stream.cc

Issue 323683002: net: FileStream cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove new methods Created 6 years, 6 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
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 #include "net/base/file_stream.h" 5 #include "net/base/file_stream.h"
6 6
7 #include "net/base/file_stream_context.h" 7 #include "net/base/file_stream_context.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 24
25 int FileStream::Open(const base::FilePath& path, int open_flags, 25 int FileStream::Open(const base::FilePath& path, int open_flags,
26 const CompletionCallback& callback) { 26 const CompletionCallback& callback) {
27 if (IsOpen()) { 27 if (IsOpen()) {
28 DLOG(FATAL) << "File is already open!"; 28 DLOG(FATAL) << "File is already open!";
29 return ERR_UNEXPECTED; 29 return ERR_UNEXPECTED;
30 } 30 }
31 31
32 DCHECK(open_flags & base::File::FLAG_ASYNC); 32 DCHECK(open_flags & base::File::FLAG_ASYNC);
33 context_->OpenAsync(path, open_flags, callback); 33 context_->Open(path, open_flags, callback);
34 return ERR_IO_PENDING; 34 return ERR_IO_PENDING;
35 } 35 }
36 36
37 int FileStream::Close(const CompletionCallback& callback) { 37 int FileStream::Close(const CompletionCallback& callback) {
38 context_->CloseAsync(callback); 38 context_->Close(callback);
39 return ERR_IO_PENDING; 39 return ERR_IO_PENDING;
40 } 40 }
41 41
42 bool FileStream::IsOpen() const { 42 bool FileStream::IsOpen() const {
43 return context_->file().IsValid(); 43 return context_->file().IsValid();
44 } 44 }
45 45
46 int FileStream::Seek(Whence whence, 46 int FileStream::Seek(base::File::Whence whence,
47 int64 offset, 47 int64 offset,
48 const Int64CompletionCallback& callback) { 48 const Int64CompletionCallback& callback) {
49 if (!IsOpen()) 49 if (!IsOpen())
50 return ERR_UNEXPECTED; 50 return ERR_UNEXPECTED;
51 51
52 context_->SeekAsync(whence, offset, callback); 52 context_->Seek(whence, offset, callback);
53 return ERR_IO_PENDING; 53 return ERR_IO_PENDING;
54 } 54 }
55 55
56 int FileStream::Read(IOBuffer* buf, 56 int FileStream::Read(IOBuffer* buf,
57 int buf_len, 57 int buf_len,
58 const CompletionCallback& callback) { 58 const CompletionCallback& callback) {
59 if (!IsOpen()) 59 if (!IsOpen())
60 return ERR_UNEXPECTED; 60 return ERR_UNEXPECTED;
61 61
62 // read(..., 0) will return 0, which indicates end-of-file. 62 // read(..., 0) will return 0, which indicates end-of-file.
63 DCHECK_GT(buf_len, 0); 63 DCHECK_GT(buf_len, 0);
64 64
65 return context_->ReadAsync(buf, buf_len, callback); 65 return context_->Read(buf, buf_len, callback);
66 } 66 }
67 67
68 int FileStream::Write(IOBuffer* buf, 68 int FileStream::Write(IOBuffer* buf,
69 int buf_len, 69 int buf_len,
70 const CompletionCallback& callback) { 70 const CompletionCallback& callback) {
71 if (!IsOpen()) 71 if (!IsOpen())
72 return ERR_UNEXPECTED; 72 return ERR_UNEXPECTED;
73 73
74 // write(..., 0) will return 0, which indicates end-of-file. 74 return context_->Write(buf, buf_len, callback);
hashimoto 2014/06/19 01:51:56 nit: Why did you remove DCHECK here while keeping
rvargas (doing something else) 2014/06/19 17:11:43 It was suggested by wtc, given that there is no EO
75 DCHECK_GT(buf_len, 0);
76
77 return context_->WriteAsync(buf, buf_len, callback);
78 } 75 }
79 76
80 int FileStream::Flush(const CompletionCallback& callback) { 77 int FileStream::Flush(const CompletionCallback& callback) {
81 if (!IsOpen()) 78 if (!IsOpen())
82 return ERR_UNEXPECTED; 79 return ERR_UNEXPECTED;
83 80
84 context_->FlushAsync(callback); 81 context_->Flush(callback);
85 return ERR_IO_PENDING; 82 return ERR_IO_PENDING;
86 } 83 }
87 84
88 const base::File& FileStream::GetFileForTesting() const { 85 const base::File& FileStream::GetFileForTesting() const {
89 return context_->file(); 86 return context_->file();
90 } 87 }
91 88
92 } // namespace net 89 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698