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

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

Issue 11275223: net: Change type of UploadData::elements from std::vector to ScopedVector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move ParamTraits to ipc_message_utils.h Created 8 years, 1 month 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
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_data.h" 5 #include "net/base/upload_data.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/worker_pool.h" 10 #include "base/threading/worker_pool.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 UploadData::UploadData() 14 UploadData::UploadData()
15 : identifier_(0), 15 : identifier_(0),
16 is_chunked_(false), 16 is_chunked_(false),
17 last_chunk_appended_(false) { 17 last_chunk_appended_(false) {
18 } 18 }
19 19
20 void UploadData::AppendBytes(const char* bytes, int bytes_len) { 20 void UploadData::AppendBytes(const char* bytes, int bytes_len) {
21 DCHECK(!is_chunked_); 21 DCHECK(!is_chunked_);
22 if (bytes_len > 0) { 22 if (bytes_len > 0) {
23 elements_.push_back(UploadElement()); 23 elements_.push_back(new UploadElement());
24 elements_.back().SetToBytes(bytes, bytes_len); 24 elements_.back()->SetToBytes(bytes, bytes_len);
25 } 25 }
26 } 26 }
27 27
28 void UploadData::AppendFileRange(const FilePath& file_path, 28 void UploadData::AppendFileRange(const FilePath& file_path,
29 uint64 offset, uint64 length, 29 uint64 offset, uint64 length,
30 const base::Time& expected_modification_time) { 30 const base::Time& expected_modification_time) {
31 DCHECK(!is_chunked_); 31 DCHECK(!is_chunked_);
32 elements_.push_back(UploadElement()); 32 elements_.push_back(new UploadElement());
33 elements_.back().SetToFilePathRange(file_path, offset, length, 33 elements_.back()->SetToFilePathRange(file_path, offset, length,
34 expected_modification_time); 34 expected_modification_time);
35 } 35 }
36 36
37 void UploadData::AppendChunk(const char* bytes, 37 void UploadData::AppendChunk(const char* bytes,
38 int bytes_len, 38 int bytes_len,
39 bool is_last_chunk) { 39 bool is_last_chunk) {
40 DCHECK(is_chunked_); 40 DCHECK(is_chunked_);
41 DCHECK(!last_chunk_appended_); 41 DCHECK(!last_chunk_appended_);
42 elements_.push_back(UploadElement()); 42 elements_.push_back(new UploadElement());
43 elements_.back().SetToBytes(bytes, bytes_len); 43 elements_.back()->SetToBytes(bytes, bytes_len);
44 last_chunk_appended_ = is_last_chunk; 44 last_chunk_appended_ = is_last_chunk;
45 if (!chunk_callback_.is_null()) 45 if (!chunk_callback_.is_null())
46 chunk_callback_.Run(); 46 chunk_callback_.Run();
47 } 47 }
48 48
49 void UploadData::set_chunk_callback(const base::Closure& callback) { 49 void UploadData::set_chunk_callback(const base::Closure& callback) {
50 chunk_callback_ = callback; 50 chunk_callback_ = callback;
51 } 51 }
52 52
53 void UploadData::SetElements(const std::vector<UploadElement>& elements) {
54 elements_ = elements;
55 }
56
57 UploadData::~UploadData() { 53 UploadData::~UploadData() {
58 } 54 }
59 55
60 } // namespace net 56 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698