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

Side by Side Diff: webkit/glue/webupload_data.cc

Issue 10834289: Split net::UploadData into two: for IPC and for upload handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "webkit/glue/webupload_data.h"
6
7 #include "base/logging.h"
8 #include "net/base/upload_data.h"
9
10 WebUploadData::Element::Element()
11 : type_(TYPE_BYTES),
12 file_range_offset_(0),
13 file_range_length_(kuint64max) {
14 }
15
16 WebUploadData::Element::~Element() {}
17
18 WebUploadData::WebUploadData() : identifier_(0) {}
19
20 void WebUploadData::AppendBytes(const char* bytes, int bytes_len) {
21 if (bytes_len > 0) {
22 elements_.push_back(Element());
23 elements_.back().SetToBytes(bytes, bytes_len);
24 }
25 }
26
27 void WebUploadData::AppendFileRange(
28 const FilePath& file_path,
29 uint64 offset, uint64 length,
30 const base::Time& expected_modification_time) {
31 elements_.push_back(Element());
32 elements_.back().SetToFilePathRange(file_path, offset, length,
33 expected_modification_time);
34 }
35
36 void WebUploadData::AppendBlob(const GURL& blob_url) {
37 elements_.push_back(Element());
38 elements_.back().SetToBlobUrl(blob_url);
39 }
40
41 void WebUploadData::PopulateUploadData(net::UploadData* upload_data) const {
42 DCHECK(upload_data);
43 DCHECK(!upload_data->is_chunked());
44 std::vector<net::UploadData::Element>* uploads =
45 upload_data->elements_mutable();
46 for (size_t i = 0; i < elements_.size(); ++i) {
47 const Element& element = elements_[i];
48 if (element.type() == TYPE_BYTES) {
49 uploads->push_back(net::UploadData::Element());
50 // TODO(kinuko): Avoid this data copy.
51 uploads->back().SetToBytes(element.bytes().data(),
52 element.bytes().size());
53 continue;
54 }
55
56 DCHECK(element.type() == TYPE_FILE);
57 uploads->push_back(net::UploadData::Element());
58 uploads->back().SetToFilePathRange(
59 element.file_path(),
60 element.file_range_offset(),
61 element.file_range_length(),
62 element.expected_file_modification_time());
63 }
64 }
65
66 WebUploadData::~WebUploadData() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698