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 #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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/supports_user_data.h" | |
16 #include "base/time.h" | 17 #include "base/time.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 | 22 |
22 class FileStream; | 23 class FileStream; |
23 | 24 |
24 // Interface implemented by callers who require callbacks when new chunks | 25 // Interface implemented by callers who require callbacks when new chunks |
25 // of data are added. | 26 // of data are added. |
26 class NET_EXPORT_PRIVATE ChunkCallback { | 27 class NET_EXPORT_PRIVATE ChunkCallback { |
27 public: | 28 public: |
28 // Invoked when a new data chunk was given for a chunked transfer upload. | 29 // Invoked when a new data chunk was given for a chunked transfer upload. |
29 virtual void OnChunkAvailable() = 0; | 30 virtual void OnChunkAvailable() = 0; |
30 | 31 |
31 protected: | 32 protected: |
32 virtual ~ChunkCallback() {} | 33 virtual ~ChunkCallback() {} |
33 }; | 34 }; |
34 | 35 |
35 class NET_EXPORT UploadData : public base::RefCounted<UploadData> { | 36 class NET_EXPORT UploadData |
37 : public base::RefCounted<UploadData>, | |
38 public base::SupportsUserData { | |
willchan no longer on Chromium
2012/03/01 22:57:23
It'd be great to add comments for what this is use
michaeln
2012/03/02 02:23:58
Done.
| |
36 public: | 39 public: |
37 enum Type { | 40 enum Type { |
38 TYPE_BYTES, | 41 TYPE_BYTES, |
39 TYPE_FILE, | 42 TYPE_FILE, |
40 TYPE_BLOB, | 43 TYPE_BLOB, |
41 | 44 |
42 // A block of bytes to be sent in chunked encoding immediately, without | 45 // A block of bytes to be sent in chunked encoding immediately, without |
43 // waiting for rest of the data. | 46 // waiting for rest of the data. |
44 TYPE_CHUNK, | 47 TYPE_CHUNK, |
45 }; | 48 }; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 // sessions. A value of 0 is used to indicate an unspecified identifier. | 227 // sessions. A value of 0 is used to indicate an unspecified identifier. |
225 void set_identifier(int64 id) { identifier_ = id; } | 228 void set_identifier(int64 id) { identifier_ = id; } |
226 int64 identifier() const { return identifier_; } | 229 int64 identifier() const { return identifier_; } |
227 | 230 |
228 private: | 231 private: |
229 // Helper function for GetContentLength(). | 232 // Helper function for GetContentLength(). |
230 void DoGetContentLength(uint64* content_length); | 233 void DoGetContentLength(uint64* content_length); |
231 | 234 |
232 friend class base::RefCounted<UploadData>; | 235 friend class base::RefCounted<UploadData>; |
233 | 236 |
234 ~UploadData(); | 237 virtual ~UploadData(); |
235 | 238 |
236 std::vector<Element> elements_; | 239 std::vector<Element> elements_; |
237 int64 identifier_; | 240 int64 identifier_; |
238 ChunkCallback* chunk_callback_; | 241 ChunkCallback* chunk_callback_; |
239 bool is_chunked_; | 242 bool is_chunked_; |
240 | 243 |
241 DISALLOW_COPY_AND_ASSIGN(UploadData); | 244 DISALLOW_COPY_AND_ASSIGN(UploadData); |
242 }; | 245 }; |
243 | 246 |
244 #if defined(UNIT_TEST) | 247 #if defined(UNIT_TEST) |
(...skipping 17 matching lines...) Expand all Loading... | |
262 | 265 |
263 inline bool operator!=(const UploadData::Element& a, | 266 inline bool operator!=(const UploadData::Element& a, |
264 const UploadData::Element& b) { | 267 const UploadData::Element& b) { |
265 return !(a == b); | 268 return !(a == b); |
266 } | 269 } |
267 #endif // defined(UNIT_TEST) | 270 #endif // defined(UNIT_TEST) |
268 | 271 |
269 } // namespace net | 272 } // namespace net |
270 | 273 |
271 #endif // NET_BASE_UPLOAD_DATA_H_ | 274 #endif // NET_BASE_UPLOAD_DATA_H_ |
OLD | NEW |