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