OLD | NEW |
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return true; | 109 return true; |
110 } | 110 } |
111 | 111 |
112 void X509UserCertResourceHandler::OnRequestClosed() { | 112 void X509UserCertResourceHandler::OnRequestClosed() { |
113 } | 113 } |
114 | 114 |
115 X509UserCertResourceHandler::~X509UserCertResourceHandler() { | 115 X509UserCertResourceHandler::~X509UserCertResourceHandler() { |
116 } | 116 } |
117 | 117 |
118 void X509UserCertResourceHandler::AssembleResource() { | 118 void X509UserCertResourceHandler::AssembleResource() { |
119 size_t assembled_bytes = 0; | 119 // 0-length IOBuffers are not allowed. |
120 resource_buffer_ = content::AssembleData(buffer_, &assembled_bytes); | 120 if (content_length_ == 0) { |
121 DCHECK_EQ(content_length_, assembled_bytes); | 121 resource_buffer_ = NULL; |
| 122 return; |
| 123 } |
| 124 |
| 125 // Create the new buffer. |
| 126 resource_buffer_ = new net::IOBuffer(content_length_); |
| 127 |
| 128 // Copy the data into it. |
| 129 size_t bytes_copied = 0; |
| 130 for (size_t i = 0; i < buffer_.size(); ++i) { |
| 131 net::IOBuffer* data = buffer_[i].first; |
| 132 size_t data_len = buffer_[i].second; |
| 133 DCHECK(data != NULL); |
| 134 DCHECK_LE(bytes_copied + data_len, content_length_); |
| 135 memcpy(resource_buffer_->data() + bytes_copied, data->data(), data_len); |
| 136 bytes_copied += data_len; |
| 137 } |
| 138 DCHECK_EQ(content_length_, bytes_copied); |
122 } | 139 } |
OLD | NEW |