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

Side by Side Diff: webkit/glue/resource_request_body.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: fixes 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/resource_request_body.h"
6
7 #include "base/logging.h"
8 #include "net/base/upload_data.h"
9
10 namespace webkit_glue {
11
12 ResourceRequestBody::Element::Element()
13 : type_(TYPE_BYTES),
14 bytes_start_(NULL),
15 bytes_length_(0),
16 file_range_offset_(0),
17 file_range_length_(kuint64max) {
18 }
19
20 ResourceRequestBody::Element::~Element() {}
21
22 ResourceRequestBody::ResourceRequestBody() : identifier_(0) {}
23
24 void ResourceRequestBody::AppendBytes(const char* bytes, int bytes_len) {
25 if (bytes_len > 0) {
26 elements_.push_back(Element());
27 elements_.back().SetToBytes(bytes, bytes_len);
28 }
29 }
30
31 void ResourceRequestBody::AppendFileRange(
32 const FilePath& file_path,
33 uint64 offset, uint64 length,
34 const base::Time& expected_modification_time) {
35 elements_.push_back(Element());
36 elements_.back().SetToFilePathRange(file_path, offset, length,
37 expected_modification_time);
38 }
39
40 void ResourceRequestBody::AppendBlob(const GURL& blob_url) {
41 elements_.push_back(Element());
42 elements_.back().SetToBlobUrl(blob_url);
43 }
44
45 void ResourceRequestBody::PopulateUploadData(
46 net::UploadData* upload_data) {
47 DCHECK(upload_data);
48 DCHECK(!upload_data->is_chunked());
49 upload_data->SetUserData(
darin (slow to review) 2012/08/15 17:49:55 Oh, I see! You should add a comment about how thi
kinuko 2012/08/16 08:14:59 Done.
50 this, new base::UserDataAdapter<ResourceRequestBody>(this));
51 std::vector<net::UploadData::Element>* uploads =
52 upload_data->elements_mutable();
53 for (size_t i = 0; i < elements_.size(); ++i) {
54 const Element& element = elements_[i];
55 if (element.type() == TYPE_BYTES) {
56 uploads->push_back(net::UploadData::Element());
57 uploads->back().SetToSharedBytes(element.bytes(),
58 element.bytes_length());
59 continue;
60 }
61
62 DCHECK(element.type() == TYPE_FILE);
63 uploads->push_back(net::UploadData::Element());
64 uploads->back().SetToFilePathRange(
65 element.file_path(),
66 element.file_range_offset(),
67 element.file_range_length(),
68 element.expected_file_modification_time());
69 }
70 upload_data->set_identifier(identifier_);
71 }
72
73 ResourceRequestBody::~ResourceRequestBody() {}
74
75 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698