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

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: sorin@'s 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 if (!is_async()) {
mmenke 2013/09/09 15:03:09 All the other sync calls are preceded by a: base:
waffles 2013/09/09 22:50:56 Done.
98 context_->CloseSync();
99 context_.reset();
mmenke 2013/09/09 15:03:09 Erm....Doesn't this result in a crash on destructi
waffles 2013/09/09 22:50:56 Hm, yes, I agree.
100 return OK;
101 }
102 context_->CloseAsync(callback);
103 return ERR_IO_PENDING;
104 }
105
96 bool FileStream::IsOpen() const { 106 bool FileStream::IsOpen() const {
97 return context_->file() != base::kInvalidPlatformFileValue; 107 return context_->file() != base::kInvalidPlatformFileValue;
98 } 108 }
99 109
100 int FileStream::Seek(Whence whence, 110 int FileStream::Seek(Whence whence,
101 int64 offset, 111 int64 offset,
102 const Int64CompletionCallback& callback) { 112 const Int64CompletionCallback& callback) {
103 if (!IsOpen()) 113 if (!IsOpen())
104 return ERR_UNEXPECTED; 114 return ERR_UNEXPECTED;
105 115
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 286
277 owner_bound_net_log.AddEvent(NetLog::TYPE_FILE_STREAM_SOURCE, 287 owner_bound_net_log.AddEvent(NetLog::TYPE_FILE_STREAM_SOURCE,
278 bound_net_log_.source().ToEventParametersCallback()); 288 bound_net_log_.source().ToEventParametersCallback());
279 } 289 }
280 290
281 base::PlatformFile FileStream::GetPlatformFileForTesting() { 291 base::PlatformFile FileStream::GetPlatformFileForTesting() {
282 return context_->file(); 292 return context_->file();
283 } 293 }
284 294
285 } // namespace net 295 } // 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