| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_X509_USER_CERT_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_X509_USER_CERT_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_X509_USER_CERT_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_X509_USER_CERT_RESOURCE_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } // namespace net | 22 } // namespace net |
| 23 | 23 |
| 24 // This class handles the "application/x-x509-user-cert" mime-type | 24 // This class handles the "application/x-x509-user-cert" mime-type |
| 25 // which is a certificate generated by a CA after a previous | 25 // which is a certificate generated by a CA after a previous |
| 26 // <keygen> form post. | 26 // <keygen> form post. |
| 27 | 27 |
| 28 class X509UserCertResourceHandler : public ResourceHandler { | 28 class X509UserCertResourceHandler : public ResourceHandler { |
| 29 public: | 29 public: |
| 30 X509UserCertResourceHandler(ResourceDispatcherHost* host, | 30 X509UserCertResourceHandler(ResourceDispatcherHost* host, |
| 31 net::URLRequest* request, | 31 net::URLRequest* request, |
| 32 int render_process_host_id, int render_view_id); | 32 int render_process_host_id, |
| 33 int render_view_id); |
| 33 | 34 |
| 34 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); | 35 virtual bool OnUploadProgress(int request_id, |
| 36 uint64 position, |
| 37 uint64 size) OVERRIDE; |
| 35 | 38 |
| 36 // Not needed, as this event handler ought to be the final resource. | 39 // Not needed, as this event handler ought to be the final resource. |
| 37 virtual bool OnRequestRedirected(int request_id, const GURL& url, | 40 virtual bool OnRequestRedirected(int request_id, |
| 38 ResourceResponse* resp, bool* defer); | 41 const GURL& url, |
| 42 ResourceResponse* resp, |
| 43 bool* defer) OVERRIDE; |
| 39 | 44 |
| 40 // Check if this indeed an X509 cert. | 45 // Check if this indeed an X509 cert. |
| 41 virtual bool OnResponseStarted(int request_id, ResourceResponse* resp); | 46 virtual bool OnResponseStarted(int request_id, |
| 47 ResourceResponse* resp) OVERRIDE; |
| 42 | 48 |
| 43 // Pass-through implementation. | 49 // Pass-through implementation. |
| 44 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); | 50 virtual bool OnWillStart(int request_id, |
| 51 const GURL& url, |
| 52 bool* defer) OVERRIDE; |
| 45 | 53 |
| 46 // Create a new buffer to store received data. | 54 // Create a new buffer to store received data. |
| 47 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, | 55 virtual bool OnWillRead(int request_id, |
| 48 int min_size); | 56 net::IOBuffer** buf, |
| 57 int* buf_size, |
| 58 int min_size) OVERRIDE; |
| 49 | 59 |
| 50 // A read was completed, maybe allocate a new buffer for further data. | 60 // A read was completed, maybe allocate a new buffer for further data. |
| 51 virtual bool OnReadCompleted(int request_id, int* bytes_read); | 61 virtual bool OnReadCompleted(int request_id, |
| 62 int* bytes_read) OVERRIDE; |
| 52 | 63 |
| 53 // Done downloading the certificate. | 64 // Done downloading the certificate. |
| 54 virtual bool OnResponseCompleted(int request_id, | 65 virtual bool OnResponseCompleted(int request_id, |
| 55 const net::URLRequestStatus& urs, | 66 const net::URLRequestStatus& urs, |
| 56 const std::string& sec_info); | 67 const std::string& sec_info) OVERRIDE; |
| 57 | 68 |
| 58 virtual void OnRequestClosed(); | 69 virtual void OnRequestClosed() OVERRIDE; |
| 59 | 70 |
| 60 private: | 71 private: |
| 61 virtual ~X509UserCertResourceHandler(); | 72 virtual ~X509UserCertResourceHandler(); |
| 62 | 73 |
| 63 void AssembleResource(); | 74 void AssembleResource(); |
| 64 | 75 |
| 65 GURL url_; | 76 GURL url_; |
| 66 ResourceDispatcherHost* host_; | 77 ResourceDispatcherHost* host_; |
| 67 net::URLRequest* request_; | 78 net::URLRequest* request_; |
| 68 size_t content_length_; | 79 size_t content_length_; |
| 69 content::ContentVector buffer_; | 80 content::ContentVector buffer_; |
| 70 scoped_refptr<net::IOBuffer> read_buffer_; | 81 scoped_refptr<net::IOBuffer> read_buffer_; |
| 71 scoped_refptr<net::IOBuffer> resource_buffer_; // Downloaded certificate. | 82 scoped_refptr<net::IOBuffer> resource_buffer_; // Downloaded certificate. |
| 72 static const int kReadBufSize = 32768; | 83 static const int kReadBufSize = 32768; |
| 73 // The id of the |RenderProcessHost| which started the download. | 84 // The id of the |RenderProcessHost| which started the download. |
| 74 int render_process_host_id_; | 85 int render_process_host_id_; |
| 75 // The id of the |RenderView| which started the download. | 86 // The id of the |RenderView| which started the download. |
| 76 int render_view_id_; | 87 int render_view_id_; |
| 77 | 88 |
| 78 DISALLOW_COPY_AND_ASSIGN(X509UserCertResourceHandler); | 89 DISALLOW_COPY_AND_ASSIGN(X509UserCertResourceHandler); |
| 79 }; | 90 }; |
| 80 | 91 |
| 81 #endif // CONTENT_BROWSER_RENDERER_HOST_X509_USER_CERT_RESOURCE_HANDLER_H_ | 92 #endif // CONTENT_BROWSER_RENDERER_HOST_X509_USER_CERT_RESOURCE_HANDLER_H_ |
| OLD | NEW |