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

Side by Side Diff: content/browser/loader/certificate_resource_handler.cc

Issue 25536005: Clean up ResourceHandler API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 2 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/loader/certificate_resource_handler.h" 5 #include "content/browser/loader/certificate_resource_handler.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "content/browser/loader/resource_request_info_impl.h" 8 #include "content/browser/loader/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"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "net/base/mime_sniffer.h" 12 #include "net/base/mime_sniffer.h"
13 #include "net/base/mime_util.h" 13 #include "net/base/mime_util.h"
14 #include "net/http/http_response_headers.h" 14 #include "net/http/http_response_headers.h"
15 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
16 #include "net/url_request/url_request_status.h" 16 #include "net/url_request/url_request_status.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 CertificateResourceHandler::CertificateResourceHandler( 20 CertificateResourceHandler::CertificateResourceHandler(
21 net::URLRequest* request) 21 net::URLRequest* request)
22 : request_(request), 22 : ResourceHandler(request),
23 content_length_(0), 23 content_length_(0),
24 read_buffer_(NULL), 24 read_buffer_(NULL),
25 resource_buffer_(NULL), 25 resource_buffer_(NULL),
26 cert_type_(net::CERTIFICATE_MIME_TYPE_UNKNOWN) { 26 cert_type_(net::CERTIFICATE_MIME_TYPE_UNKNOWN) {
27 } 27 }
28 28
29 CertificateResourceHandler::~CertificateResourceHandler() { 29 CertificateResourceHandler::~CertificateResourceHandler() {
30 } 30 }
31 31
32 bool CertificateResourceHandler::OnUploadProgress(int request_id, 32 bool CertificateResourceHandler::OnUploadProgress(int request_id,
(...skipping 17 matching lines...) Expand all
50 return cert_type_ != net::CERTIFICATE_MIME_TYPE_UNKNOWN; 50 return cert_type_ != net::CERTIFICATE_MIME_TYPE_UNKNOWN;
51 } 51 }
52 52
53 bool CertificateResourceHandler::OnWillStart(int request_id, 53 bool CertificateResourceHandler::OnWillStart(int request_id,
54 const GURL& url, 54 const GURL& url,
55 bool* defer) { 55 bool* defer) {
56 return true; 56 return true;
57 } 57 }
58 58
59 bool CertificateResourceHandler::OnWillRead(int request_id, 59 bool CertificateResourceHandler::OnWillRead(int request_id,
60 net::IOBuffer** buf, 60 scoped_refptr<net::IOBuffer>* buf,
61 int* buf_size, 61 int* buf_size,
62 int min_size) { 62 int min_size) {
63 static const int kReadBufSize = 32768; 63 static const int kReadBufSize = 32768;
64 64
65 // TODO(gauravsh): Should we use 'min_size' here? 65 // TODO(gauravsh): Should we use 'min_size' here?
66 DCHECK(buf && buf_size); 66 DCHECK(buf && buf_size);
67 if (!read_buffer_.get()) { 67 if (!read_buffer_.get()) {
68 read_buffer_ = new net::IOBuffer(kReadBufSize); 68 read_buffer_ = new net::IOBuffer(kReadBufSize);
69 } 69 }
70 *buf = read_buffer_.get(); 70 *buf = read_buffer_.get();
(...skipping 30 matching lines...) Expand all
101 return false; 101 return false;
102 102
103 AssembleResource(); 103 AssembleResource();
104 104
105 const void* content_bytes = NULL; 105 const void* content_bytes = NULL;
106 if (resource_buffer_.get()) 106 if (resource_buffer_.get())
107 content_bytes = resource_buffer_->data(); 107 content_bytes = resource_buffer_->data();
108 108
109 // Note that it's up to the browser to verify that the certificate 109 // Note that it's up to the browser to verify that the certificate
110 // data is well-formed. 110 // data is well-formed.
111 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); 111 const ResourceRequestInfo* info = GetRequestInfo();
112 GetContentClient()->browser()->AddCertificate( 112 GetContentClient()->browser()->AddCertificate(
113 request_, cert_type_, content_bytes, content_length_, 113 request(), cert_type_, content_bytes, content_length_,
114 info->GetChildID(), info->GetRouteID()); 114 info->GetChildID(), info->GetRouteID());
115 115
116 return true; 116 return true;
117 } 117 }
118 118
119 void CertificateResourceHandler::AssembleResource() { 119 void CertificateResourceHandler::AssembleResource() {
120 // 0-length IOBuffers are not allowed. 120 // 0-length IOBuffers are not allowed.
121 if (content_length_ == 0) { 121 if (content_length_ == 0) {
122 resource_buffer_ = NULL; 122 resource_buffer_ = NULL;
123 return; 123 return;
(...skipping 15 matching lines...) Expand all
139 DCHECK_EQ(content_length_, bytes_copied); 139 DCHECK_EQ(content_length_, bytes_copied);
140 } 140 }
141 141
142 void CertificateResourceHandler::OnDataDownloaded( 142 void CertificateResourceHandler::OnDataDownloaded(
143 int request_id, 143 int request_id,
144 int bytes_downloaded) { 144 int bytes_downloaded) {
145 NOTREACHED(); 145 NOTREACHED();
146 } 146 }
147 147
148 } // namespace content 148 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/certificate_resource_handler.h ('k') | content/browser/loader/cross_site_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698