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 30 matching lines...) Expand all Loading... | |
41 // waiting for rest of the data. | 41 // waiting for rest of the data. |
42 TYPE_CHUNK, | 42 TYPE_CHUNK, |
43 }; | 43 }; |
44 | 44 |
45 class Element { | 45 class Element { |
46 public: | 46 public: |
47 Element(); | 47 Element(); |
48 ~Element(); | 48 ~Element(); |
49 | 49 |
50 Type type() const { return type_; } | 50 Type type() const { return type_; } |
51 // Explicitly sets the type of this Element. Used during IPC | |
52 // marshaling. | |
eroman
2011/01/26 03:42:29
nit: I believe the spelling is "marshalling" (two
ananta
2011/01/26 03:46:09
Done.
| |
53 void set_type(Type type) { | |
54 type_ = type; | |
55 } | |
56 | |
51 const std::vector<char>& bytes() const { return bytes_; } | 57 const std::vector<char>& bytes() const { return bytes_; } |
52 const FilePath& file_path() const { return file_path_; } | 58 const FilePath& file_path() const { return file_path_; } |
53 uint64 file_range_offset() const { return file_range_offset_; } | 59 uint64 file_range_offset() const { return file_range_offset_; } |
54 uint64 file_range_length() const { return file_range_length_; } | 60 uint64 file_range_length() const { return file_range_length_; } |
55 // If NULL time is returned, we do not do the check. | 61 // If NULL time is returned, we do not do the check. |
56 const base::Time& expected_file_modification_time() const { | 62 const base::Time& expected_file_modification_time() const { |
57 return expected_file_modification_time_; | 63 return expected_file_modification_time_; |
58 } | 64 } |
59 const GURL& blob_url() const { return blob_url_; } | 65 const GURL& blob_url() const { return blob_url_; } |
60 | 66 |
(...skipping 25 matching lines...) Expand all Loading... | |
86 type_ = TYPE_BLOB; | 92 type_ = TYPE_BLOB; |
87 blob_url_ = blob_url; | 93 blob_url_ = blob_url; |
88 } | 94 } |
89 | 95 |
90 // 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 |
91 // chunked transfer encoding and not buffered until the full upload data | 97 // chunked transfer encoding and not buffered until the full upload data |
92 // is available. | 98 // is available. |
93 void SetToChunk(const char* bytes, int bytes_len); | 99 void SetToChunk(const char* bytes, int bytes_len); |
94 | 100 |
95 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 marshaling | |
eroman
2011/01/26 03:42:29
ditto to above. Also please end in period.
ananta
2011/01/26 03:46:09
Done.
| |
103 void set_is_last_chunk(bool is_last_chunk) { | |
104 is_last_chunk_ = is_last_chunk; | |
105 } | |
96 | 106 |
97 // 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 |
98 // is returned. This is done for consistency with Mozilla. | 108 // is returned. This is done for consistency with Mozilla. |
99 // Once called, this function will always return the same value. | 109 // Once called, this function will always return the same value. |
100 uint64 GetContentLength(); | 110 uint64 GetContentLength(); |
101 | 111 |
102 // Returns a FileStream opened for reading for this element, positioned at | 112 // Returns a FileStream opened for reading for this element, positioned at |
103 // |file_range_offset_|. The caller gets ownership and is responsible | 113 // |file_range_offset_|. The caller gets ownership and is responsible |
104 // for cleaning up the FileStream. Returns NULL if this element is not of | 114 // for cleaning up the FileStream. Returns NULL if this element is not of |
105 // type TYPE_FILE or if the file is not openable. | 115 // type TYPE_FILE or if the file is not openable. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 | 217 |
208 inline bool operator!=(const UploadData::Element& a, | 218 inline bool operator!=(const UploadData::Element& a, |
209 const UploadData::Element& b) { | 219 const UploadData::Element& b) { |
210 return !(a == b); | 220 return !(a == b); |
211 } | 221 } |
212 #endif // defined(UNIT_TEST) | 222 #endif // defined(UNIT_TEST) |
213 | 223 |
214 } // namespace net | 224 } // namespace net |
215 | 225 |
216 #endif // NET_BASE_UPLOAD_DATA_H_ | 226 #endif // NET_BASE_UPLOAD_DATA_H_ |
OLD | NEW |