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

Side by Side Diff: net/base/upload_bytes_element_reader.cc

Issue 11439008: net: Change argument of URLRequest::set_upload from UploadData to UploadDataStream (Closed) Base URL: http://git.chromium.org/chromium/src.git@chunk
Patch Set: Fix android Created 8 years 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
« no previous file with comments | « net/base/upload_bytes_element_reader.h ('k') | net/base/upload_data_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/upload_bytes_element_reader.h" 5 #include "net/base/upload_bytes_element_reader.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h"
8 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
9 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
10 11
11 namespace net { 12 namespace net {
12 13
13 UploadBytesElementReader::UploadBytesElementReader(const char* bytes, 14 UploadBytesElementReader::UploadBytesElementReader(const char* bytes,
14 int length) 15 uint64 length)
15 : bytes_(bytes), 16 : bytes_(bytes),
16 length_(length), 17 length_(length),
17 offset_(0) { 18 offset_(0) {
18 } 19 }
19 20
20 UploadBytesElementReader::~UploadBytesElementReader() { 21 UploadBytesElementReader::~UploadBytesElementReader() {
21 } 22 }
22 23
23 const UploadBytesElementReader* 24 const UploadBytesElementReader*
24 UploadBytesElementReader::AsBytesReader() const { 25 UploadBytesElementReader::AsBytesReader() const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Check if we have anything to copy first, because we are getting 63 // Check if we have anything to copy first, because we are getting
63 // the address of an element in |bytes_| and that will throw an 64 // the address of an element in |bytes_| and that will throw an
64 // exception if |bytes_| is an empty vector. 65 // exception if |bytes_| is an empty vector.
65 if (num_bytes_to_read > 0) 66 if (num_bytes_to_read > 0)
66 memcpy(buf->data(), bytes_ + offset_, num_bytes_to_read); 67 memcpy(buf->data(), bytes_ + offset_, num_bytes_to_read);
67 68
68 offset_ += num_bytes_to_read; 69 offset_ += num_bytes_to_read;
69 return num_bytes_to_read; 70 return num_bytes_to_read;
70 } 71 }
71 72
73
74 UploadOwnedBytesElementReader::UploadOwnedBytesElementReader(
75 std::vector<char>* data)
76 : UploadBytesElementReader(vector_as_array(data), data->size()) {
77 data_.swap(*data);
78 }
79
80 UploadOwnedBytesElementReader::~UploadOwnedBytesElementReader() {}
81
82 UploadOwnedBytesElementReader*
83 UploadOwnedBytesElementReader::CreateWithString(const std::string& string) {
84 std::vector<char> data(string.begin(), string.end());
85 return new UploadOwnedBytesElementReader(&data);
86 }
87
72 } // namespace net 88 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_bytes_element_reader.h ('k') | net/base/upload_data_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698