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

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

Issue 23500006: URLFetcher won't call delegate until file is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke's 3rd review Created 7 years, 3 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
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/file_stream_context.h » ('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 #include "net/base/file_stream.h" 5 #include "net/base/file_stream.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (IsOpen()) { 86 if (IsOpen()) {
87 DLOG(FATAL) << "File is already open!"; 87 DLOG(FATAL) << "File is already open!";
88 return ERR_UNEXPECTED; 88 return ERR_UNEXPECTED;
89 } 89 }
90 90
91 open_flags_ = open_flags; 91 open_flags_ = open_flags;
92 DCHECK(!is_async()); 92 DCHECK(!is_async());
93 return context_->OpenSync(path, open_flags_); 93 return context_->OpenSync(path, open_flags_);
94 } 94 }
95 95
96 int FileStream::Close(const CompletionCallback& callback) {
97 DCHECK(is_async());
98 context_->CloseAsync(callback);
99 return ERR_IO_PENDING;
100 }
101
102 int FileStream::CloseSync() {
103 DCHECK(!is_async());
104 base::ThreadRestrictions::AssertIOAllowed();
105 context_->CloseSync();
106 return OK;
107 }
108
96 bool FileStream::IsOpen() const { 109 bool FileStream::IsOpen() const {
97 return context_->file() != base::kInvalidPlatformFileValue; 110 return context_->file() != base::kInvalidPlatformFileValue;
98 } 111 }
99 112
100 int FileStream::Seek(Whence whence, 113 int FileStream::Seek(Whence whence,
101 int64 offset, 114 int64 offset,
102 const Int64CompletionCallback& callback) { 115 const Int64CompletionCallback& callback) {
103 if (!IsOpen()) 116 if (!IsOpen())
104 return ERR_UNEXPECTED; 117 return ERR_UNEXPECTED;
105 118
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 289
277 owner_bound_net_log.AddEvent(NetLog::TYPE_FILE_STREAM_SOURCE, 290 owner_bound_net_log.AddEvent(NetLog::TYPE_FILE_STREAM_SOURCE,
278 bound_net_log_.source().ToEventParametersCallback()); 291 bound_net_log_.source().ToEventParametersCallback());
279 } 292 }
280 293
281 base::PlatformFile FileStream::GetPlatformFileForTesting() { 294 base::PlatformFile FileStream::GetPlatformFileForTesting() {
282 return context_->file(); 295 return context_->file();
283 } 296 }
284 297
285 } // namespace net 298 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/file_stream_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698