OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_COMMON_RESOURCE_REQUEST_BODY_H_ | 5 #ifndef CONTENT_COMMON_RESOURCE_REQUEST_BODY_IMPL_H_ |
6 #define CONTENT_COMMON_RESOURCE_REQUEST_BODY_H_ | 6 #define CONTENT_COMMON_RESOURCE_REQUEST_BODY_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/common/resource_request_body.h" |
16 #include "storage/common/data_element.h" | 17 #include "storage/common/data_element.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class FilePath; | 21 class FilePath; |
21 } | 22 } |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
25 // A struct used to represent upload data. The data field is populated by | 26 // A struct used to represent upload data. The data field is populated by |
26 // WebURLLoader from the data given as WebHTTPBody. | 27 // WebURLLoader from the data given as WebHTTPBody. |
27 class CONTENT_EXPORT ResourceRequestBody | 28 class CONTENT_EXPORT ResourceRequestBodyImpl : public ResourceRequestBody, |
28 : public base::RefCountedThreadSafe<ResourceRequestBody>, | 29 public base::SupportsUserData { |
29 public base::SupportsUserData { | |
30 public: | 30 public: |
31 typedef storage::DataElement Element; | 31 typedef storage::DataElement Element; |
32 | 32 |
33 ResourceRequestBody(); | 33 ResourceRequestBodyImpl(); |
34 | 34 |
35 void AppendBytes(const char* bytes, int bytes_len); | 35 void AppendBytes(const char* bytes, int bytes_len); |
36 void AppendFileRange(const base::FilePath& file_path, | 36 void AppendFileRange(const base::FilePath& file_path, |
37 uint64_t offset, | 37 uint64_t offset, |
38 uint64_t length, | 38 uint64_t length, |
39 const base::Time& expected_modification_time); | 39 const base::Time& expected_modification_time); |
40 void AppendBlob(const std::string& uuid); | 40 void AppendBlob(const std::string& uuid); |
41 void AppendFileSystemFileRange(const GURL& url, | 41 void AppendFileSystemFileRange(const GURL& url, |
42 uint64_t offset, | 42 uint64_t offset, |
43 uint64_t length, | 43 uint64_t length, |
44 const base::Time& expected_modification_time); | 44 const base::Time& expected_modification_time); |
45 | 45 |
46 const std::vector<Element>* elements() const { return &elements_; } | 46 const std::vector<Element>* elements() const { return &elements_; } |
47 std::vector<Element>* elements_mutable() { return &elements_; } | 47 std::vector<Element>* elements_mutable() { return &elements_; } |
48 void swap_elements(std::vector<Element>* elements) { | 48 void swap_elements(std::vector<Element>* elements) { |
49 elements_.swap(*elements); | 49 elements_.swap(*elements); |
50 } | 50 } |
51 | 51 |
52 // Identifies a particular upload instance, which is used by the cache to | 52 // Identifies a particular upload instance, which is used by the cache to |
53 // formulate a cache key. This value should be unique across browser | 53 // formulate a cache key. This value should be unique across browser |
54 // sessions. A value of 0 is used to indicate an unspecified identifier. | 54 // sessions. A value of 0 is used to indicate an unspecified identifier. |
55 void set_identifier(int64_t id) { identifier_ = id; } | 55 void set_identifier(int64_t id) { identifier_ = id; } |
56 int64_t identifier() const { return identifier_; } | 56 int64_t identifier() const { return identifier_; } |
57 | 57 |
58 private: | 58 private: |
59 friend class base::RefCountedThreadSafe<ResourceRequestBody>; | 59 ~ResourceRequestBodyImpl() override; |
60 ~ResourceRequestBody() override; | |
61 | 60 |
62 std::vector<Element> elements_; | 61 std::vector<Element> elements_; |
63 int64_t identifier_; | 62 int64_t identifier_; |
64 | 63 |
65 DISALLOW_COPY_AND_ASSIGN(ResourceRequestBody); | 64 DISALLOW_COPY_AND_ASSIGN(ResourceRequestBodyImpl); |
66 }; | 65 }; |
67 | 66 |
68 } // namespace content | 67 } // namespace content |
69 | 68 |
70 #endif // CONTENT_COMMON_RESOURCE_REQUEST_BODY_H_ | 69 #endif // CONTENT_COMMON_RESOURCE_REQUEST_BODY_IMPL_H_ |
OLD | NEW |