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

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

Issue 10701050: net: Implement canceling of all async operations in FileStream. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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
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/upload_file_element_reader.h" 5 #include "net/base/upload_file_element_reader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 23 matching lines...) Expand all
34 if (rv != OK) { 34 if (rv != OK) {
35 // If the file can't be opened, we'll just upload an empty file. 35 // If the file can't be opened, we'll just upload an empty file.
36 DLOG(WARNING) << "Failed to open \"" << path.value() 36 DLOG(WARNING) << "Failed to open \"" << path.value()
37 << "\" for reading: " << rv; 37 << "\" for reading: " << rv;
38 file_stream.reset(); 38 file_stream.reset();
39 } else if (range_offset) { 39 } else if (range_offset) {
40 rv = file_stream->SeekSync(FROM_BEGIN, range_offset); 40 rv = file_stream->SeekSync(FROM_BEGIN, range_offset);
41 if (rv < 0) { 41 if (rv < 0) {
42 DLOG(WARNING) << "Failed to seek \"" << path.value() 42 DLOG(WARNING) << "Failed to seek \"" << path.value()
43 << "\" to offset: " << range_offset << " (" << rv << ")"; 43 << "\" to offset: " << range_offset << " (" << rv << ")";
44 file_stream->CloseSync();
45 file_stream.reset(); 44 file_stream.reset();
46 } 45 }
47 } 46 }
48 47
49 int64 length = 0; 48 int64 length = 0;
50 if (file_stream.get() && 49 if (file_stream.get() &&
51 file_util::GetFileSize(path, &length) && 50 file_util::GetFileSize(path, &length) &&
52 range_offset < static_cast<uint64>(length)) { 51 range_offset < static_cast<uint64>(length)) {
53 // Compensate for the offset. 52 // Compensate for the offset.
54 length = std::min(length - range_offset, range_length); 53 length = std::min(length - range_offset, range_length);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 ScopedOverridingContentLengthForTests(uint64 value) { 241 ScopedOverridingContentLengthForTests(uint64 value) {
243 overriding_content_length = value; 242 overriding_content_length = value;
244 } 243 }
245 244
246 UploadFileElementReader::ScopedOverridingContentLengthForTests:: 245 UploadFileElementReader::ScopedOverridingContentLengthForTests::
247 ~ScopedOverridingContentLengthForTests() { 246 ~ScopedOverridingContentLengthForTests() {
248 overriding_content_length = 0; 247 overriding_content_length = 0;
249 } 248 }
250 249
251 } // namespace net 250 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698