1 // Copyright 2013 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.
5 #ifndef WEBKIT_COMMON_RESOURCE_REQUEST_BODY_H_
6 #define WEBKIT_COMMON_RESOURCE_REQUEST_BODY_H_
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/supports_user_data.h"
14 #include "webkit/common/data_element.h"
15 #include "webkit/common/webkit_common_export.h"
21 namespace webkit_glue
{
23 // A struct used to represent upload data. The data field is populated by
24 // WebURLLoader from the data given as WebHTTPBody.
25 class WEBKIT_COMMON_EXPORT ResourceRequestBody
26 : public base::RefCounted
<ResourceRequestBody
>,
27 public base::SupportsUserData
{
29 typedef webkit_common::DataElement Element
;
31 ResourceRequestBody();
33 void AppendBytes(const char* bytes
, int bytes_len
);
34 void AppendFileRange(const base::FilePath
& file_path
,
35 uint64 offset
, uint64 length
,
36 const base::Time
& expected_modification_time
);
37 void AppendBlobDeprecated(const GURL
& blob_url
);
38 void AppendBlob(const std::string
& uuid
);
39 void AppendFileSystemFileRange(const GURL
& url
, uint64 offset
, uint64 length
,
40 const base::Time
& expected_modification_time
);
42 const std::vector
<Element
>* elements() const { return &elements_
; }
43 std::vector
<Element
>* elements_mutable() { return &elements_
; }
44 void swap_elements(std::vector
<Element
>* elements
) {
45 elements_
.swap(*elements
);
48 // Identifies a particular upload instance, which is used by the cache to
49 // formulate a cache key. This value should be unique across browser
50 // sessions. A value of 0 is used to indicate an unspecified identifier.
51 void set_identifier(int64 id
) { identifier_
= id
; }
52 int64
identifier() const { return identifier_
; }
55 friend class base::RefCounted
<ResourceRequestBody
>;
56 virtual ~ResourceRequestBody();
58 std::vector
<Element
> elements_
;
61 DISALLOW_COPY_AND_ASSIGN(ResourceRequestBody
);
64 } // namespace webkit_glue
66 #endif // WEBKIT_COMMON_RESOURCE_REQUEST_BODY_H_