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

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

Issue 10332130: Use defer out-params instead of ResourceDispatcherHostImpl::PauseRequest(...true) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « content/browser/renderer_host/x509_user_cert_resource_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 int request_id, 38 int request_id,
39 const GURL& url, 39 const GURL& url,
40 content::ResourceResponse* resp, 40 content::ResourceResponse* resp,
41 bool* defer) { 41 bool* defer) {
42 url_ = url; 42 url_ = url;
43 return true; 43 return true;
44 } 44 }
45 45
46 bool X509UserCertResourceHandler::OnResponseStarted( 46 bool X509UserCertResourceHandler::OnResponseStarted(
47 int request_id, 47 int request_id,
48 content::ResourceResponse* resp) { 48 content::ResourceResponse* resp,
49 bool* defer) {
49 return (resp->mime_type == "application/x-x509-user-cert"); 50 return (resp->mime_type == "application/x-x509-user-cert");
50 } 51 }
51 52
52 bool X509UserCertResourceHandler::OnWillStart(int request_id, 53 bool X509UserCertResourceHandler::OnWillStart(int request_id,
53 const GURL& url, 54 const GURL& url,
54 bool* defer) { 55 bool* defer) {
55 return true; 56 return true;
56 } 57 }
57 58
58 bool X509UserCertResourceHandler::OnWillRead(int request_id, 59 bool X509UserCertResourceHandler::OnWillRead(int request_id,
59 net::IOBuffer** buf, 60 net::IOBuffer** buf,
60 int* buf_size, 61 int* buf_size,
61 int min_size) { 62 int min_size) {
62 static const int kReadBufSize = 32768; 63 static const int kReadBufSize = 32768;
63 64
64 // TODO(gauravsh): Should we use 'min_size' here? 65 // TODO(gauravsh): Should we use 'min_size' here?
65 DCHECK(buf && buf_size); 66 DCHECK(buf && buf_size);
66 if (!read_buffer_) { 67 if (!read_buffer_) {
67 read_buffer_ = new net::IOBuffer(kReadBufSize); 68 read_buffer_ = new net::IOBuffer(kReadBufSize);
68 } 69 }
69 *buf = read_buffer_.get(); 70 *buf = read_buffer_.get();
70 *buf_size = kReadBufSize; 71 *buf_size = kReadBufSize;
71 72
72 return true; 73 return true;
73 } 74 }
74 75
75 bool X509UserCertResourceHandler::OnReadCompleted(int request_id, 76 bool X509UserCertResourceHandler::OnReadCompleted(int request_id,
76 int* bytes_read) { 77 int* bytes_read,
78 bool* defer) {
77 if (!*bytes_read) 79 if (!*bytes_read)
78 return true; 80 return true;
79 81
80 // We have more data to read. 82 // We have more data to read.
81 DCHECK(read_buffer_); 83 DCHECK(read_buffer_);
82 content_length_ += *bytes_read; 84 content_length_ += *bytes_read;
83 85
84 // Release the ownership of the buffer, and store a reference 86 // Release the ownership of the buffer, and store a reference
85 // to it. A new one will be allocated in OnWillRead(). 87 // to it. A new one will be allocated in OnWillRead().
86 net::IOBuffer* buffer = NULL; 88 net::IOBuffer* buffer = NULL;
(...skipping 26 matching lines...) Expand all
113 } 115 }
114 116
115 X509UserCertResourceHandler::~X509UserCertResourceHandler() { 117 X509UserCertResourceHandler::~X509UserCertResourceHandler() {
116 } 118 }
117 119
118 void X509UserCertResourceHandler::AssembleResource() { 120 void X509UserCertResourceHandler::AssembleResource() {
119 size_t assembled_bytes = 0; 121 size_t assembled_bytes = 0;
120 resource_buffer_ = content::AssembleData(buffer_, &assembled_bytes); 122 resource_buffer_ = content::AssembleData(buffer_, &assembled_bytes);
121 DCHECK_EQ(content_length_, assembled_bytes); 123 DCHECK_EQ(content_length_, assembled_bytes);
122 } 124 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/x509_user_cert_resource_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698