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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 void UploadData::AppendFileRange(const FilePath& file_path, | 39 void UploadData::AppendFileRange(const FilePath& file_path, |
40 uint64 offset, uint64 length, | 40 uint64 offset, uint64 length, |
41 const base::Time& expected_modification_time) { | 41 const base::Time& expected_modification_time) { |
42 DCHECK(!is_chunked_); | 42 DCHECK(!is_chunked_); |
43 elements_.push_back(UploadElement()); | 43 elements_.push_back(UploadElement()); |
44 elements_.back().SetToFilePathRange(file_path, offset, length, | 44 elements_.back().SetToFilePathRange(file_path, offset, length, |
45 expected_modification_time); | 45 expected_modification_time); |
46 } | 46 } |
47 | 47 |
48 void UploadData::AppendBlob(const GURL& blob_url) { | |
49 DCHECK(!is_chunked_); | |
50 elements_.push_back(UploadElement()); | |
51 elements_.back().SetToBlobUrl(blob_url); | |
52 } | |
53 | |
54 void UploadData::AppendChunk(const char* bytes, | 48 void UploadData::AppendChunk(const char* bytes, |
55 int bytes_len, | 49 int bytes_len, |
56 bool is_last_chunk) { | 50 bool is_last_chunk) { |
57 DCHECK(is_chunked_); | 51 DCHECK(is_chunked_); |
58 elements_.push_back(UploadElement()); | 52 elements_.push_back(UploadElement()); |
59 elements_.back().SetToChunk(bytes, bytes_len, is_last_chunk); | 53 elements_.back().SetToChunk(bytes, bytes_len, is_last_chunk); |
60 if (chunk_callback_) | 54 if (chunk_callback_) |
61 chunk_callback_->OnChunkAvailable(); | 55 chunk_callback_->OnChunkAvailable(); |
62 } | 56 } |
63 | 57 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return; | 108 return; |
115 | 109 |
116 for (size_t i = 0; i < elements_.size(); ++i) | 110 for (size_t i = 0; i < elements_.size(); ++i) |
117 *content_length += elements_[i].GetContentLength(); | 111 *content_length += elements_[i].GetContentLength(); |
118 } | 112 } |
119 | 113 |
120 UploadData::~UploadData() { | 114 UploadData::~UploadData() { |
121 } | 115 } |
122 | 116 |
123 } // namespace net | 117 } // namespace net |
OLD | NEW |