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

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

Issue 10828252: Support FileSystem URL in File object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/upload_data.h" 5 #include "net/base/upload_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 uint64 UploadData::Element::GetContentLength() { 63 uint64 UploadData::Element::GetContentLength() {
64 if (override_content_length_ || content_length_computed_) 64 if (override_content_length_ || content_length_computed_)
65 return content_length_; 65 return content_length_;
66 66
67 if (type_ == TYPE_BYTES || type_ == TYPE_CHUNK) 67 if (type_ == TYPE_BYTES || type_ == TYPE_CHUNK)
68 return static_cast<uint64>(bytes_.size()); 68 return static_cast<uint64>(bytes_.size());
69 else if (type_ == TYPE_BLOB) 69 else if (type_ == TYPE_BLOB)
70 // The blob reference will be resolved later. 70 // The blob reference will be resolved later.
71 return 0; 71 return 0;
72 72
73 // Assume we have no TYPE_FILE_FILESYSTEM items at this stage.
74
73 DCHECK_EQ(TYPE_FILE, type_); 75 DCHECK_EQ(TYPE_FILE, type_);
74 DCHECK(!file_stream_); 76 DCHECK(!file_stream_);
75 77
76 // TODO(darin): This size calculation could be out of sync with the state of 78 // TODO(darin): This size calculation could be out of sync with the state of
77 // the file when we get around to reading it. We should probably find a way 79 // the file when we get around to reading it. We should probably find a way
78 // to lock the file or somehow protect against this error condition. 80 // to lock the file or somehow protect against this error condition.
79 81
80 content_length_computed_ = true; 82 content_length_computed_ = true;
81 content_length_ = 0; 83 content_length_ = 0;
82 84
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 225
224 void UploadData::AppendFileRange(const FilePath& file_path, 226 void UploadData::AppendFileRange(const FilePath& file_path,
225 uint64 offset, uint64 length, 227 uint64 offset, uint64 length,
226 const base::Time& expected_modification_time) { 228 const base::Time& expected_modification_time) {
227 DCHECK(!is_chunked_); 229 DCHECK(!is_chunked_);
228 elements_.push_back(Element()); 230 elements_.push_back(Element());
229 elements_.back().SetToFilePathRange(file_path, offset, length, 231 elements_.back().SetToFilePathRange(file_path, offset, length,
230 expected_modification_time); 232 expected_modification_time);
231 } 233 }
232 234
235 void UploadData::AppendFileSystemFileRange(
236 const GURL& url,
237 uint64 offset, uint64 length,
238 const base::Time& expected_modification_time) {
239 DCHECK(!is_chunked_);
240 elements_.push_back(Element());
241 elements_.back().SetToFileSystemURLRange(url, offset, length,
242 expected_modification_time);
243 }
244
233 void UploadData::AppendBlob(const GURL& blob_url) { 245 void UploadData::AppendBlob(const GURL& blob_url) {
234 DCHECK(!is_chunked_); 246 DCHECK(!is_chunked_);
235 elements_.push_back(Element()); 247 elements_.push_back(Element());
236 elements_.back().SetToBlobUrl(blob_url); 248 elements_.back().SetToBlobUrl(blob_url);
237 } 249 }
238 250
239 void UploadData::AppendChunk(const char* bytes, 251 void UploadData::AppendChunk(const char* bytes,
240 int bytes_len, 252 int bytes_len,
241 bool is_last_chunk) { 253 bool is_last_chunk) {
242 DCHECK(is_chunked_); 254 DCHECK(is_chunked_);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 return; 311 return;
300 312
301 for (size_t i = 0; i < elements_.size(); ++i) 313 for (size_t i = 0; i < elements_.size(); ++i)
302 *content_length += elements_[i].GetContentLength(); 314 *content_length += elements_[i].GetContentLength();
303 } 315 }
304 316
305 UploadData::~UploadData() { 317 UploadData::~UploadData() {
306 } 318 }
307 319
308 } // namespace net 320 } // namespace net
OLDNEW
« net/base/upload_data.h ('K') | « net/base/upload_data.h ('k') | webkit/blob/blob_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698