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 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 #include "net/base/upload_element.h" | 13 #include "net/base/upload_element.h" |
14 | 14 |
| 15 namespace base { |
15 class FilePath; | 16 class FilePath; |
16 | |
17 namespace base { | |
18 class Time; | 17 class Time; |
19 } // namespace base | 18 } // namespace base |
20 | 19 |
21 namespace net { | 20 namespace net { |
22 | 21 |
23 //----------------------------------------------------------------------------- | 22 //----------------------------------------------------------------------------- |
24 // A very concrete class representing the data to be uploaded as part of a | 23 // A very concrete class representing the data to be uploaded as part of a |
25 // URLRequest. | 24 // URLRequest. |
26 // | 25 // |
27 // Until there is a more abstract class for this, this one derives from | 26 // Until there is a more abstract class for this, this one derives from |
28 // SupportsUserData to allow users to stash random data by | 27 // SupportsUserData to allow users to stash random data by |
29 // key and ensure its destruction when UploadData is finally deleted. | 28 // key and ensure its destruction when UploadData is finally deleted. |
30 class NET_EXPORT UploadData | 29 class NET_EXPORT UploadData |
31 : public base::RefCounted<UploadData>, | 30 : public base::RefCounted<UploadData>, |
32 public base::SupportsUserData { | 31 public base::SupportsUserData { |
33 public: | 32 public: |
34 UploadData(); | 33 UploadData(); |
35 | 34 |
36 void AppendBytes(const char* bytes, int bytes_len); | 35 void AppendBytes(const char* bytes, int bytes_len); |
37 | 36 |
38 void AppendFileRange(const FilePath& file_path, | 37 void AppendFileRange(const base::FilePath& file_path, |
39 uint64 offset, uint64 length, | 38 uint64 offset, uint64 length, |
40 const base::Time& expected_modification_time); | 39 const base::Time& expected_modification_time); |
41 | 40 |
42 // Initializes the object to send chunks of upload data over time rather | 41 // Initializes the object to send chunks of upload data over time rather |
43 // than all at once. Chunked data may only contain bytes, not files. | 42 // than all at once. Chunked data may only contain bytes, not files. |
44 void set_is_chunked(bool set) { is_chunked_ = set; } | 43 void set_is_chunked(bool set) { is_chunked_ = set; } |
45 bool is_chunked() const { return is_chunked_; } | 44 bool is_chunked() const { return is_chunked_; } |
46 | 45 |
47 // set_last_chunk_appended() is only used for serialization. | 46 // set_last_chunk_appended() is only used for serialization. |
48 void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; } | 47 void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; } |
(...skipping 26 matching lines...) Expand all Loading... |
75 int64 identifier_; | 74 int64 identifier_; |
76 bool is_chunked_; | 75 bool is_chunked_; |
77 bool last_chunk_appended_; | 76 bool last_chunk_appended_; |
78 | 77 |
79 DISALLOW_COPY_AND_ASSIGN(UploadData); | 78 DISALLOW_COPY_AND_ASSIGN(UploadData); |
80 }; | 79 }; |
81 | 80 |
82 } // namespace net | 81 } // namespace net |
83 | 82 |
84 #endif // NET_BASE_UPLOAD_DATA_H_ | 83 #endif // NET_BASE_UPLOAD_DATA_H_ |
OLD | NEW |