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

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

Issue 11419034: net: Move ownership of UploadDataStream from URLRequestHttpJob to URLRequest (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove a local variable 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 "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 UploadBytesElementReader::UploadBytesElementReader(const char* bytes, 13 UploadBytesElementReader::UploadBytesElementReader(const char* bytes,
14 int bytes_length) 14 int length)
15 : bytes_(bytes), 15 : bytes_(bytes),
16 bytes_length_(bytes_length), 16 length_(length),
17 offset_(0) { 17 offset_(0) {
18 } 18 }
19 19
20 UploadBytesElementReader::~UploadBytesElementReader() { 20 UploadBytesElementReader::~UploadBytesElementReader() {
21 } 21 }
22 22
23 const UploadBytesElementReader*
24 UploadBytesElementReader::AsBytesReader() const {
25 return this;
26 }
27
23 int UploadBytesElementReader::Init(const CompletionCallback& callback) { 28 int UploadBytesElementReader::Init(const CompletionCallback& callback) {
24 return InitSync(); 29 return InitSync();
25 } 30 }
26 31
27 int UploadBytesElementReader::InitSync() { 32 int UploadBytesElementReader::InitSync() {
28 offset_ = 0; 33 offset_ = 0;
29 return OK; 34 return OK;
30 } 35 }
31 36
32 uint64 UploadBytesElementReader::GetContentLength() const { 37 uint64 UploadBytesElementReader::GetContentLength() const {
33 return bytes_length_; 38 return length_;
34 } 39 }
35 40
36 uint64 UploadBytesElementReader::BytesRemaining() const { 41 uint64 UploadBytesElementReader::BytesRemaining() const {
37 return bytes_length_ - offset_; 42 return length_ - offset_;
38 } 43 }
39 44
40 bool UploadBytesElementReader::IsInMemory() const { 45 bool UploadBytesElementReader::IsInMemory() const {
41 return true; 46 return true;
42 } 47 }
43 48
44 int UploadBytesElementReader::Read(IOBuffer* buf, 49 int UploadBytesElementReader::Read(IOBuffer* buf,
45 int buf_length, 50 int buf_length,
46 const CompletionCallback& callback) { 51 const CompletionCallback& callback) {
47 DCHECK(!callback.is_null()); 52 DCHECK(!callback.is_null());
(...skipping 10 matching lines...) Expand all
58 // the address of an element in |bytes_| and that will throw an 63 // the address of an element in |bytes_| and that will throw an
59 // exception if |bytes_| is an empty vector. 64 // exception if |bytes_| is an empty vector.
60 if (num_bytes_to_read > 0) 65 if (num_bytes_to_read > 0)
61 memcpy(buf->data(), bytes_ + offset_, num_bytes_to_read); 66 memcpy(buf->data(), bytes_ + offset_, num_bytes_to_read);
62 67
63 offset_ += num_bytes_to_read; 68 offset_ += num_bytes_to_read;
64 return num_bytes_to_read; 69 return num_bytes_to_read;
65 } 70 }
66 71
67 } // namespace net 72 } // 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