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

Side by Side Diff: content/browser/renderer_host/x509_user_cert_resource_handler.cc

Issue 10392111: Use ByteStream in downloads system to decouple source and sink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments. Created 8 years, 6 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 | 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 "content/browser/renderer_host/x509_user_cert_resource_handler.h" 5 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "content/browser/renderer_host/resource_request_info_impl.h" 8 #include "content/browser/renderer_host/resource_request_info_impl.h"
9 #include "content/public/browser/content_browser_client.h" 9 #include "content/public/browser/content_browser_client.h"
10 #include "content/public/common/resource_response.h" 10 #include "content/public/common/resource_response.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return true; 111 return true;
112 } 112 }
113 113
114 void X509UserCertResourceHandler::OnRequestClosed() { 114 void X509UserCertResourceHandler::OnRequestClosed() {
115 } 115 }
116 116
117 X509UserCertResourceHandler::~X509UserCertResourceHandler() { 117 X509UserCertResourceHandler::~X509UserCertResourceHandler() {
118 } 118 }
119 119
120 void X509UserCertResourceHandler::AssembleResource() { 120 void X509UserCertResourceHandler::AssembleResource() {
121 size_t assembled_bytes = 0; 121 // 0-length IOBuffers are not allowed.
122 resource_buffer_ = content::AssembleData(buffer_, &assembled_bytes); 122 if (content_length_ == 0) {
123 DCHECK_EQ(content_length_, assembled_bytes); 123 resource_buffer_ = NULL;
124 return;
125 }
126
127 // Create the new buffer.
128 resource_buffer_ = new net::IOBuffer(content_length_);
129
130 // Copy the data into it.
131 size_t bytes_copied = 0;
132 for (size_t i = 0; i < buffer_.size(); ++i) {
133 net::IOBuffer* data = buffer_[i].first;
134 size_t data_len = buffer_[i].second;
135 DCHECK(data != NULL);
136 DCHECK_LE(bytes_copied + data_len, content_length_);
137 memcpy(resource_buffer_->data() + bytes_copied, data->data(), data_len);
138 bytes_copied += data_len;
139 }
140 DCHECK_EQ(content_length_, bytes_copied);
124 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698