blob: 60dcb2913bbddebbec6bc13628abf6e72b34a4dd [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <vector>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/supports_user_data.h"
#include "content/common/content_export.h"
#include "storage/common/data_element.h"
#include "url/gurl.h"
namespace base {
class FilePath;
namespace content {
// A struct used to represent upload data. The data field is populated by
// WebURLLoader from the data given as WebHTTPBody.
class CONTENT_EXPORT ResourceRequestBody
: public base::RefCountedThreadSafe<ResourceRequestBody>,
public base::SupportsUserData {
typedef storage::DataElement Element;
void AppendBytes(const char* bytes, int bytes_len);
void AppendFileRange(const base::FilePath& file_path,
uint64 offset, uint64 length,
const base::Time& expected_modification_time);
void AppendBlob(const std::string& uuid);
void AppendFileSystemFileRange(const GURL& url, uint64 offset, uint64 length,
const base::Time& expected_modification_time);
const std::vector<Element>* elements() const { return &elements_; }
std::vector<Element>* elements_mutable() { return &elements_; }
void swap_elements(std::vector<Element>* elements) {
// Identifies a particular upload instance, which is used by the cache to
// formulate a cache key. This value should be unique across browser
// sessions. A value of 0 is used to indicate an unspecified identifier.
void set_identifier(int64 id) { identifier_ = id; }
int64 identifier() const { return identifier_; }
friend class base::RefCountedThreadSafe<ResourceRequestBody>;
~ResourceRequestBody() override;
std::vector<Element> elements_;
int64 identifier_;
} // namespace content