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

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: Sync'd to LKGR. 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (resource_buffer_) { 108 if (resource_buffer_) {
109 cert = net::X509Certificate::CreateFromBytes(resource_buffer_->data(), 109 cert = net::X509Certificate::CreateFromBytes(resource_buffer_->data(),
110 content_length_); 110 content_length_);
111 } 111 }
112 GetContentClient()->browser()->AddNewCertificate( 112 GetContentClient()->browser()->AddNewCertificate(
113 request_, cert, render_process_host_id_, render_view_id_); 113 request_, cert, render_process_host_id_, render_view_id_);
114 return true; 114 return true;
115 } 115 }
116 116
117 void X509UserCertResourceHandler::AssembleResource() { 117 void X509UserCertResourceHandler::AssembleResource() {
118 size_t assembled_bytes = 0; 118 // 0-length IOBuffers are not allowed.
119 resource_buffer_ = AssembleData(buffer_, &assembled_bytes); 119 if (content_length_ == 0) {
120 DCHECK_EQ(content_length_, assembled_bytes); 120 resource_buffer_ = NULL;
121 return;
122 }
123
124 // Create the new buffer.
125 resource_buffer_ = new net::IOBuffer(content_length_);
126
127 // Copy the data into it.
128 size_t bytes_copied = 0;
129 for (size_t i = 0; i < buffer_.size(); ++i) {
130 net::IOBuffer* data = buffer_[i].first;
131 size_t data_len = buffer_[i].second;
132 DCHECK(data != NULL);
133 DCHECK_LE(bytes_copied + data_len, content_length_);
134 memcpy(resource_buffer_->data() + bytes_copied, data->data(), data_len);
135 bytes_copied += data_len;
136 }
137 DCHECK_EQ(content_length_, bytes_copied);
121 } 138 }
122 139
123 } // namespace content 140 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/x509_user_cert_resource_handler.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698