Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: net/base/chunked_upload_data_stream.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/chunked_upload_data_stream.h ('k') | net/base/chunked_upload_data_stream_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/chunked_upload_data_stream.cc
diff --git a/net/base/chunked_upload_data_stream.cc b/net/base/chunked_upload_data_stream.cc
deleted file mode 100644
index f1fbf0822c854af2eae4b9d87b41a057775409a0..0000000000000000000000000000000000000000
--- a/net/base/chunked_upload_data_stream.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-// 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 "net/base/chunked_upload_data_stream.h"
-
-#include "base/logging.h"
-#include "base/stl_util.h"
-#include "net/base/io_buffer.h"
-#include "net/base/net_errors.h"
-
-namespace net {
-
-ChunkedUploadDataStream::ChunkedUploadDataStream(int64 identifier)
- : UploadDataStream(true, identifier),
- read_index_(0),
- read_offset_(0),
- all_data_appended_(false),
- read_buffer_len_(0) {
-}
-
-ChunkedUploadDataStream::~ChunkedUploadDataStream() {
-}
-
-void ChunkedUploadDataStream::AppendData(
- const char* data, int data_len, bool is_done) {
- DCHECK(!all_data_appended_);
- DCHECK(data_len > 0 || is_done);
- if (data_len > 0) {
- DCHECK(data);
- upload_data_.push_back(new std::vector<char>(data, data + data_len));
- }
- all_data_appended_ = is_done;
-
- if (!read_buffer_.get())
- return;
-
- int result = ReadChunk(read_buffer_.get(), read_buffer_len_);
- // Shouldn't get an error or ERR_IO_PENDING.
- DCHECK_GE(result, 0);
- read_buffer_ = NULL;
- read_buffer_len_ = 0;
- OnReadCompleted(result);
-}
-
-int ChunkedUploadDataStream::InitInternal() {
- // ResetInternal should already have been called.
- DCHECK(!read_buffer_.get());
- DCHECK_EQ(0u, read_index_);
- DCHECK_EQ(0u, read_offset_);
- return OK;
-}
-
-int ChunkedUploadDataStream::ReadInternal(IOBuffer* buf, int buf_len) {
- DCHECK_LT(0, buf_len);
- DCHECK(!read_buffer_.get());
-
- int result = ReadChunk(buf, buf_len);
- if (result == ERR_IO_PENDING) {
- read_buffer_ = buf;
- read_buffer_len_ = buf_len;
- }
- return result;
-}
-
-void ChunkedUploadDataStream::ResetInternal() {
- read_buffer_ = NULL;
- read_buffer_len_ = 0;
- read_index_ = 0;
- read_offset_ = 0;
-}
-
-int ChunkedUploadDataStream::ReadChunk(IOBuffer* buf, int buf_len) {
- // Copy as much data as possible from |upload_data_| to |buf|.
- int bytes_read = 0;
- while (read_index_ < upload_data_.size() && bytes_read < buf_len) {
- std::vector<char>* data = upload_data_[read_index_];
- size_t bytes_to_read =
- std::min(static_cast<size_t>(buf_len - bytes_read),
- data->size() - read_offset_);
- memcpy(buf->data() + bytes_read,
- vector_as_array(data) + read_offset_,
- bytes_to_read);
- bytes_read += bytes_to_read;
- read_offset_ += bytes_to_read;
- if (read_offset_ == data->size()) {
- read_index_++;
- read_offset_ = 0;
- }
- }
- DCHECK_LE(bytes_read, buf_len);
-
- // If no data was written, and not all data has been appended, return
- // ERR_IO_PENDING. The read will be completed in the next call to AppendData.
- if (bytes_read == 0 && !all_data_appended_)
- return ERR_IO_PENDING;
-
- if (read_index_ == upload_data_.size() && all_data_appended_)
- SetIsFinalChunk();
- return bytes_read;
-}
-
-} // namespace net
« no previous file with comments | « net/base/chunked_upload_data_stream.h ('k') | net/base/chunked_upload_data_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698