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

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

Issue 649763002: git cl format the second third of the net/base directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 "base/stl_util.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 UploadBytesElementReader::UploadBytesElementReader(const char* bytes, 14 UploadBytesElementReader::UploadBytesElementReader(const char* bytes,
15 uint64 length) 15 uint64 length)
16 : bytes_(bytes), 16 : bytes_(bytes), length_(length), offset_(0) {
17 length_(length),
18 offset_(0) {
19 } 17 }
20 18
21 UploadBytesElementReader::~UploadBytesElementReader() { 19 UploadBytesElementReader::~UploadBytesElementReader() {
22 } 20 }
23 21
24 const UploadBytesElementReader* 22 const UploadBytesElementReader* UploadBytesElementReader::AsBytesReader()
25 UploadBytesElementReader::AsBytesReader() const { 23 const {
26 return this; 24 return this;
27 } 25 }
28 26
29 int UploadBytesElementReader::Init(const CompletionCallback& callback) { 27 int UploadBytesElementReader::Init(const CompletionCallback& callback) {
30 offset_ = 0; 28 offset_ = 0;
31 return OK; 29 return OK;
32 } 30 }
33 31
34 uint64 UploadBytesElementReader::GetContentLength() const { 32 uint64 UploadBytesElementReader::GetContentLength() const {
35 return length_; 33 return length_;
(...skipping 18 matching lines...) Expand all
54 // Check if we have anything to copy first, because we are getting 52 // Check if we have anything to copy first, because we are getting
55 // the address of an element in |bytes_| and that will throw an 53 // the address of an element in |bytes_| and that will throw an
56 // exception if |bytes_| is an empty vector. 54 // exception if |bytes_| is an empty vector.
57 if (num_bytes_to_read > 0) 55 if (num_bytes_to_read > 0)
58 memcpy(buf->data(), bytes_ + offset_, num_bytes_to_read); 56 memcpy(buf->data(), bytes_ + offset_, num_bytes_to_read);
59 57
60 offset_ += num_bytes_to_read; 58 offset_ += num_bytes_to_read;
61 return num_bytes_to_read; 59 return num_bytes_to_read;
62 } 60 }
63 61
64
65 UploadOwnedBytesElementReader::UploadOwnedBytesElementReader( 62 UploadOwnedBytesElementReader::UploadOwnedBytesElementReader(
66 std::vector<char>* data) 63 std::vector<char>* data)
67 : UploadBytesElementReader(vector_as_array(data), data->size()) { 64 : UploadBytesElementReader(vector_as_array(data), data->size()) {
68 data_.swap(*data); 65 data_.swap(*data);
69 } 66 }
70 67
71 UploadOwnedBytesElementReader::~UploadOwnedBytesElementReader() {} 68 UploadOwnedBytesElementReader::~UploadOwnedBytesElementReader() {
69 }
72 70
73 UploadOwnedBytesElementReader* 71 UploadOwnedBytesElementReader* UploadOwnedBytesElementReader::CreateWithString(
74 UploadOwnedBytesElementReader::CreateWithString(const std::string& string) { 72 const std::string& string) {
75 std::vector<char> data(string.begin(), string.end()); 73 std::vector<char> data(string.begin(), string.end());
76 return new UploadOwnedBytesElementReader(&data); 74 return new UploadOwnedBytesElementReader(&data);
77 } 75 }
78 76
79 } // namespace net 77 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698