| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef NET_BASE_UPLOAD_DATA_H_ | 5 #ifndef NET_BASE_UPLOAD_DATA_H_ |
| 6 #define NET_BASE_UPLOAD_DATA_H_ | 6 #define NET_BASE_UPLOAD_DATA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // TODO(jianli): UploadData should not contain any blob reference. We need | 89 // TODO(jianli): UploadData should not contain any blob reference. We need |
| 90 // to define another structure to represent WebKit::WebHTTPBody. | 90 // to define another structure to represent WebKit::WebHTTPBody. |
| 91 void SetToBlobUrl(const GURL& blob_url) { | 91 void SetToBlobUrl(const GURL& blob_url) { |
| 92 type_ = TYPE_BLOB; | 92 type_ = TYPE_BLOB; |
| 93 blob_url_ = blob_url; | 93 blob_url_ = blob_url; |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Though similar to bytes, a chunk indicates that the element is sent via | 96 // Though similar to bytes, a chunk indicates that the element is sent via |
| 97 // chunked transfer encoding and not buffered until the full upload data | 97 // chunked transfer encoding and not buffered until the full upload data |
| 98 // is available. | 98 // is available. |
| 99 void SetToChunk(const char* bytes, int bytes_len); | 99 void SetToChunk(const char* bytes, int bytes_len, bool is_last_chunk); |
| 100 | 100 |
| 101 bool is_last_chunk() const { return is_last_chunk_; } | 101 bool is_last_chunk() const { return is_last_chunk_; } |
| 102 // Sets whether this is the last chunk. Used during IPC marshalling. | 102 // Sets whether this is the last chunk. Used during IPC marshalling. |
| 103 void set_is_last_chunk(bool is_last_chunk) { | 103 void set_is_last_chunk(bool is_last_chunk) { |
| 104 is_last_chunk_ = is_last_chunk; | 104 is_last_chunk_ = is_last_chunk; |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Returns the byte-length of the element. For files that do not exist, 0 | 107 // Returns the byte-length of the element. For files that do not exist, 0 |
| 108 // is returned. This is done for consistency with Mozilla. | 108 // is returned. This is done for consistency with Mozilla. |
| 109 // Once called, this function will always return the same value. | 109 // Once called, this function will always return the same value. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 void AppendFile(const FilePath& file_path); | 147 void AppendFile(const FilePath& file_path); |
| 148 | 148 |
| 149 void AppendFileRange(const FilePath& file_path, | 149 void AppendFileRange(const FilePath& file_path, |
| 150 uint64 offset, uint64 length, | 150 uint64 offset, uint64 length, |
| 151 const base::Time& expected_modification_time); | 151 const base::Time& expected_modification_time); |
| 152 | 152 |
| 153 void AppendBlob(const GURL& blob_url); | 153 void AppendBlob(const GURL& blob_url); |
| 154 | 154 |
| 155 // Adds the given chunk of bytes to be sent immediately with chunked transfer | 155 // Adds the given chunk of bytes to be sent immediately with chunked transfer |
| 156 // encoding. Set bytes_len to zero for the last chunk. | 156 // encoding. |
| 157 void AppendChunk(const char* bytes, int bytes_len); | 157 void AppendChunk(const char* bytes, int bytes_len, bool is_last_chunk); |
| 158 | 158 |
| 159 // Sets the callback to be invoked when a new chunk is available to upload. | 159 // Sets the callback to be invoked when a new chunk is available to upload. |
| 160 void set_chunk_callback(ChunkCallback* callback); | 160 void set_chunk_callback(ChunkCallback* callback); |
| 161 | 161 |
| 162 // Initializes the object to send chunks of upload data over time rather | 162 // Initializes the object to send chunks of upload data over time rather |
| 163 // than all at once. | 163 // than all at once. |
| 164 void set_is_chunked(bool set) { is_chunked_ = set; } | 164 void set_is_chunked(bool set) { is_chunked_ = set; } |
| 165 bool is_chunked() const { return is_chunked_; } | 165 bool is_chunked() const { return is_chunked_; } |
| 166 | 166 |
| 167 // Returns the total size in bytes of the data to upload. | 167 // Returns the total size in bytes of the data to upload. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 217 |
| 218 inline bool operator!=(const UploadData::Element& a, | 218 inline bool operator!=(const UploadData::Element& a, |
| 219 const UploadData::Element& b) { | 219 const UploadData::Element& b) { |
| 220 return !(a == b); | 220 return !(a == b); |
| 221 } | 221 } |
| 222 #endif // defined(UNIT_TEST) | 222 #endif // defined(UNIT_TEST) |
| 223 | 223 |
| 224 } // namespace net | 224 } // namespace net |
| 225 | 225 |
| 226 #endif // NET_BASE_UPLOAD_DATA_H_ | 226 #endif // NET_BASE_UPLOAD_DATA_H_ |
| OLD | NEW |