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