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 <vector> | |
9 | |
10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
11 #include "base/callback.h" | 9 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_vector.h" |
13 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
14 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
15 #include "net/base/upload_element.h" | 14 #include "net/base/upload_element.h" |
16 | 15 |
17 class FilePath; | 16 class FilePath; |
18 | 17 |
19 namespace base { | 18 namespace base { |
20 class Time; | 19 class Time; |
21 } // namespace base | 20 } // namespace base |
22 | 21 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 53 |
55 // Initializes the object to send chunks of upload data over time rather | 54 // Initializes the object to send chunks of upload data over time rather |
56 // than all at once. Chunked data may only contain bytes, not files. | 55 // than all at once. Chunked data may only contain bytes, not files. |
57 void set_is_chunked(bool set) { is_chunked_ = set; } | 56 void set_is_chunked(bool set) { is_chunked_ = set; } |
58 bool is_chunked() const { return is_chunked_; } | 57 bool is_chunked() const { return is_chunked_; } |
59 | 58 |
60 // set_last_chunk_appended() is only used for serialization. | 59 // set_last_chunk_appended() is only used for serialization. |
61 void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; } | 60 void set_last_chunk_appended(bool set) { last_chunk_appended_ = set; } |
62 bool last_chunk_appended() const { return last_chunk_appended_; } | 61 bool last_chunk_appended() const { return last_chunk_appended_; } |
63 | 62 |
64 const std::vector<UploadElement>* elements() const { | 63 const ScopedVector<UploadElement>& elements() const { |
| 64 return elements_; |
| 65 } |
| 66 |
| 67 ScopedVector<UploadElement>* elements_mutable() { |
65 return &elements_; | 68 return &elements_; |
66 } | 69 } |
67 | 70 |
68 std::vector<UploadElement>* elements_mutable() { | 71 void swap_elements(ScopedVector<UploadElement>* elements) { |
69 return &elements_; | |
70 } | |
71 | |
72 void SetElements(const std::vector<UploadElement>& elements); | |
73 | |
74 void swap_elements(std::vector<UploadElement>* elements) { | |
75 elements_.swap(*elements); | 72 elements_.swap(*elements); |
76 } | 73 } |
77 | 74 |
78 // Identifies a particular upload instance, which is used by the cache to | 75 // Identifies a particular upload instance, which is used by the cache to |
79 // formulate a cache key. This value should be unique across browser | 76 // formulate a cache key. This value should be unique across browser |
80 // sessions. A value of 0 is used to indicate an unspecified identifier. | 77 // sessions. A value of 0 is used to indicate an unspecified identifier. |
81 void set_identifier(int64 id) { identifier_ = id; } | 78 void set_identifier(int64 id) { identifier_ = id; } |
82 int64 identifier() const { return identifier_; } | 79 int64 identifier() const { return identifier_; } |
83 | 80 |
84 private: | 81 private: |
85 friend class base::RefCounted<UploadData>; | 82 friend class base::RefCounted<UploadData>; |
86 | 83 |
87 virtual ~UploadData(); | 84 virtual ~UploadData(); |
88 | 85 |
89 std::vector<UploadElement> elements_; | 86 ScopedVector<UploadElement> elements_; |
90 int64 identifier_; | 87 int64 identifier_; |
91 base::Closure chunk_callback_; | 88 base::Closure chunk_callback_; |
92 bool is_chunked_; | 89 bool is_chunked_; |
93 bool last_chunk_appended_; | 90 bool last_chunk_appended_; |
94 | 91 |
95 DISALLOW_COPY_AND_ASSIGN(UploadData); | 92 DISALLOW_COPY_AND_ASSIGN(UploadData); |
96 }; | 93 }; |
97 | 94 |
98 } // namespace net | 95 } // namespace net |
99 | 96 |
100 #endif // NET_BASE_UPLOAD_DATA_H_ | 97 #endif // NET_BASE_UPLOAD_DATA_H_ |
OLD | NEW |