| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (!read_buffer_) { | 70 if (!read_buffer_) { |
| 71 read_buffer_ = new net::IOBuffer(kReadBufSize); | 71 read_buffer_ = new net::IOBuffer(kReadBufSize); |
| 72 } | 72 } |
| 73 *buf = read_buffer_.get(); | 73 *buf = read_buffer_.get(); |
| 74 *buf_size = kReadBufSize; | 74 *buf_size = kReadBufSize; |
| 75 | 75 |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool X509UserCertResourceHandler::OnReadCompleted(int request_id, | 79 bool X509UserCertResourceHandler::OnReadCompleted(int request_id, |
| 80 int* bytes_read, | 80 int bytes_read, |
| 81 bool* defer) { | 81 bool* defer) { |
| 82 if (!*bytes_read) | 82 if (!bytes_read) |
| 83 return true; | 83 return true; |
| 84 | 84 |
| 85 // We have more data to read. | 85 // We have more data to read. |
| 86 DCHECK(read_buffer_); | 86 DCHECK(read_buffer_); |
| 87 content_length_ += *bytes_read; | 87 content_length_ += bytes_read; |
| 88 | 88 |
| 89 // Release the ownership of the buffer, and store a reference | 89 // Release the ownership of the buffer, and store a reference |
| 90 // to it. A new one will be allocated in OnWillRead(). | 90 // to it. A new one will be allocated in OnWillRead(). |
| 91 net::IOBuffer* buffer = NULL; | 91 net::IOBuffer* buffer = NULL; |
| 92 read_buffer_.swap(&buffer); | 92 read_buffer_.swap(&buffer); |
| 93 // TODO(gauravsh): Should this be handled by a separate thread? | 93 // TODO(gauravsh): Should this be handled by a separate thread? |
| 94 buffer_.push_back(std::make_pair(buffer, *bytes_read)); | 94 buffer_.push_back(std::make_pair(buffer, bytes_read)); |
| 95 | 95 |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool X509UserCertResourceHandler::OnResponseCompleted( | 99 bool X509UserCertResourceHandler::OnResponseCompleted( |
| 100 int request_id, | 100 int request_id, |
| 101 const net::URLRequestStatus& urs, | 101 const net::URLRequestStatus& urs, |
| 102 const std::string& sec_info) { | 102 const std::string& sec_info) { |
| 103 if (urs.status() != net::URLRequestStatus::SUCCESS) | 103 if (urs.status() != net::URLRequestStatus::SUCCESS) |
| 104 return false; | 104 return false; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 131 size_t data_len = buffer_[i].second; | 131 size_t data_len = buffer_[i].second; |
| 132 DCHECK(data != NULL); | 132 DCHECK(data != NULL); |
| 133 DCHECK_LE(bytes_copied + data_len, content_length_); | 133 DCHECK_LE(bytes_copied + data_len, content_length_); |
| 134 memcpy(resource_buffer_->data() + bytes_copied, data->data(), data_len); | 134 memcpy(resource_buffer_->data() + bytes_copied, data->data(), data_len); |
| 135 bytes_copied += data_len; | 135 bytes_copied += data_len; |
| 136 } | 136 } |
| 137 DCHECK_EQ(content_length_, bytes_copied); | 137 DCHECK_EQ(content_length_, bytes_copied); |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace content | 140 } // namespace content |
| OLD | NEW |