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

Unified Diff: net/base/upload_data.cc

Issue 10878082: net: Move file operation code from UploadData to UploadDataStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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/upload_data.h ('k') | net/base/upload_data_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/upload_data.cc
diff --git a/net/base/upload_data.cc b/net/base/upload_data.cc
index f3dc22c03ab2160b76e75e6fb80605eaa56ba8e4..e9619ddd03e4762aafb5b5923c2997c25da15605 100644
--- a/net/base/upload_data.cc
+++ b/net/base/upload_data.cc
@@ -11,17 +11,6 @@
namespace net {
-namespace {
-
-// Helper function for GetContentLength().
-void OnGetContentLengthComplete(
- const UploadData::ContentLengthCallback& callback,
- uint64* content_length) {
- callback.Run(*content_length);
-}
-
-} // namespace
-
UploadData::UploadData()
: identifier_(0),
chunk_callback_(NULL),
@@ -62,58 +51,10 @@ void UploadData::set_chunk_callback(ChunkCallback* callback) {
chunk_callback_ = callback;
}
-void UploadData::GetContentLength(const ContentLengthCallback& callback) {
- uint64* result = new uint64(0);
- const bool task_is_slow = true;
- const bool posted = base::WorkerPool::PostTaskAndReply(
- FROM_HERE,
- base::Bind(&UploadData::DoGetContentLength, this, result),
- base::Bind(&OnGetContentLengthComplete, callback, base::Owned(result)),
- task_is_slow);
- DCHECK(posted);
-}
-
-uint64 UploadData::GetContentLengthSync() {
- uint64 content_length = 0;
- DoGetContentLength(&content_length);
- return content_length;
-}
-
-bool UploadData::IsInMemory() const {
- // Chunks are in memory, but UploadData does not have all the chunks at
- // once. Chunks are provided progressively with AppendChunk() as chunks
- // are ready. Check is_chunked_ here, rather than relying on the loop
- // below, as there is a case that is_chunked_ is set to true, but the
- // first chunk is not yet delivered.
- if (is_chunked_)
- return false;
-
- for (size_t i = 0; i < elements_.size(); ++i) {
- if (elements_[i].type() != UploadElement::TYPE_BYTES)
- return false;
- }
- return true;
-}
-
-void UploadData::ResetOffset() {
- for (size_t i = 0; i < elements_.size(); ++i)
- elements_[i].ResetOffset();
-}
-
void UploadData::SetElements(const std::vector<UploadElement>& elements) {
elements_ = elements;
}
-void UploadData::DoGetContentLength(uint64* content_length) {
- *content_length = 0;
-
- if (is_chunked_)
- return;
-
- for (size_t i = 0; i < elements_.size(); ++i)
- *content_length += elements_[i].GetContentLength();
-}
-
UploadData::~UploadData() {
}
« no previous file with comments | « net/base/upload_data.h ('k') | net/base/upload_data_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698