| OLD | NEW |
| 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_data.h" | 5 #include "net/base/upload_data.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 file_stream_ = NULL; | 95 file_stream_ = NULL; |
| 96 return file; | 96 return file; |
| 97 } | 97 } |
| 98 | 98 |
| 99 // TODO(tzik): | 99 // TODO(tzik): |
| 100 // FileStream::Open and FileStream::Seek may cause blocking IO. | 100 // FileStream::Open and FileStream::Seek may cause blocking IO. |
| 101 // Temporary allow until fix: http://crbug.com/72001. | 101 // Temporary allow until fix: http://crbug.com/72001. |
| 102 base::ThreadRestrictions::ScopedAllowIO allow_io; | 102 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 103 | 103 |
| 104 scoped_ptr<FileStream> file(new FileStream(NULL)); | 104 scoped_ptr<FileStream> file(new FileStream(NULL)); |
| 105 int64 rv = file->Open(file_path_, | 105 int64 rv = file->OpenSync( |
| 106 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); | 106 file_path_, |
| 107 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); |
| 107 if (rv != OK) { | 108 if (rv != OK) { |
| 108 // If the file can't be opened, we'll just upload an empty file. | 109 // If the file can't be opened, we'll just upload an empty file. |
| 109 DLOG(WARNING) << "Failed to open \"" << file_path_.value() | 110 DLOG(WARNING) << "Failed to open \"" << file_path_.value() |
| 110 << "\" for reading: " << rv; | 111 << "\" for reading: " << rv; |
| 111 return NULL; | 112 return NULL; |
| 112 } | 113 } |
| 113 if (file_range_offset_) { | 114 if (file_range_offset_) { |
| 114 rv = file->Seek(FROM_BEGIN, file_range_offset_); | 115 rv = file->Seek(FROM_BEGIN, file_range_offset_); |
| 115 if (rv < 0) { | 116 if (rv < 0) { |
| 116 DLOG(WARNING) << "Failed to seek \"" << file_path_.value() | 117 DLOG(WARNING) << "Failed to seek \"" << file_path_.value() |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } | 195 } |
| 195 | 196 |
| 196 void UploadData::SetElements(const std::vector<Element>& elements) { | 197 void UploadData::SetElements(const std::vector<Element>& elements) { |
| 197 elements_ = elements; | 198 elements_ = elements; |
| 198 } | 199 } |
| 199 | 200 |
| 200 UploadData::~UploadData() { | 201 UploadData::~UploadData() { |
| 201 } | 202 } |
| 202 | 203 |
| 203 } // namespace net | 204 } // namespace net |
| OLD | NEW |