2014-02-05 21:35:45 +01:00
|
|
|
// Copyright (c) 2012 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.
|
|
|
|
|
2015-11-26 03:53:12 +01:00
|
|
|
#include "cef/libcef/common/net/upload_data.h"
|
2014-02-05 21:35:45 +01:00
|
|
|
|
|
|
|
#include "base/logging.h"
|
2017-04-20 21:28:17 +02:00
|
|
|
#include "base/memory/ptr_util.h"
|
2014-02-05 21:35:45 +01:00
|
|
|
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
UploadData::UploadData()
|
2017-05-17 11:29:28 +02:00
|
|
|
: identifier_(0), is_chunked_(false), last_chunk_appended_(false) {}
|
2014-02-05 21:35:45 +01:00
|
|
|
|
|
|
|
void UploadData::AppendBytes(const char* bytes, int bytes_len) {
|
|
|
|
DCHECK(!is_chunked_);
|
|
|
|
if (bytes_len > 0) {
|
2018-03-20 21:15:08 +01:00
|
|
|
elements_.push_back(std::make_unique<UploadElement>());
|
2014-02-05 21:35:45 +01:00
|
|
|
elements_.back()->SetToBytes(bytes, bytes_len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UploadData::AppendFileRange(const base::FilePath& file_path,
|
2017-05-17 11:29:28 +02:00
|
|
|
uint64_t offset,
|
|
|
|
uint64_t length,
|
2014-02-05 21:35:45 +01:00
|
|
|
const base::Time& expected_modification_time) {
|
|
|
|
DCHECK(!is_chunked_);
|
2018-03-20 21:15:08 +01:00
|
|
|
elements_.push_back(std::make_unique<UploadElement>());
|
2014-02-05 21:35:45 +01:00
|
|
|
elements_.back()->SetToFilePathRange(file_path, offset, length,
|
|
|
|
expected_modification_time);
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
UploadData::~UploadData() {}
|
2014-02-05 21:35:45 +01:00
|
|
|
|
|
|
|
} // namespace net
|