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

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

Issue 10832003: Add const accessors to URLRequest and UploadData. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Forgot to check browser_tests 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
« no previous file with comments | « net/base/upload_data.h ('k') | net/url_request/url_request.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_data_stream.h" 5 #include "net/base/upload_data_stream.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "net/base/file_stream.h" 10 #include "net/base/file_stream.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // Reset the offset, as upload_data_ may already be read (i.e. UploadData 64 // Reset the offset, as upload_data_ may already be read (i.e. UploadData
65 // can be reused for a new UploadDataStream). 65 // can be reused for a new UploadDataStream).
66 upload_data_->ResetOffset(); 66 upload_data_->ResetOffset();
67 67
68 initialized_successfully_ = true; 68 initialized_successfully_ = true;
69 return OK; 69 return OK;
70 } 70 }
71 71
72 int UploadDataStream::Read(IOBuffer* buf, int buf_len) { 72 int UploadDataStream::Read(IOBuffer* buf, int buf_len) {
73 std::vector<UploadData::Element>& elements = *upload_data_->elements(); 73 std::vector<UploadData::Element>& elements =
74 *upload_data_->elements_mutable();
74 75
75 int bytes_copied = 0; 76 int bytes_copied = 0;
76 while (bytes_copied < buf_len && element_index_ < elements.size()) { 77 while (bytes_copied < buf_len && element_index_ < elements.size()) {
77 UploadData::Element& element = elements[element_index_]; 78 UploadData::Element& element = elements[element_index_];
78 79
79 bytes_copied += element.ReadSync(buf->data() + bytes_copied, 80 bytes_copied += element.ReadSync(buf->data() + bytes_copied,
80 buf_len - bytes_copied); 81 buf_len - bytes_copied);
81 82
82 if (element.BytesRemaining() == 0) 83 if (element.BytesRemaining() == 0)
83 ++element_index_; 84 ++element_index_;
(...skipping 24 matching lines...) Expand all
108 return false; 109 return false;
109 } 110 }
110 111
111 bool UploadDataStream::IsInMemory() const { 112 bool UploadDataStream::IsInMemory() const {
112 DCHECK(initialized_successfully_); 113 DCHECK(initialized_successfully_);
113 114
114 return upload_data_->IsInMemory(); 115 return upload_data_->IsInMemory();
115 } 116 }
116 117
117 } // namespace net 118 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_data.h ('k') | net/url_request/url_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698