Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_LOADER_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_LOADER_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "content/browser/renderer_host/resource_handler.h" | |
| 11 #include "content/browser/ssl/ssl_error_handler.h" | |
| 12 #include "content/public/browser/resource_controller.h" | |
| 13 #include "net/url_request/url_request.h" | |
| 14 | |
| 15 class SSLClientAuthHandler; | |
| 16 | |
| 17 namespace content { | |
| 18 class ResourceDispatcherHostLoginDelegate; | |
| 19 class ResourceLoaderDelegate; | |
| 20 class ResourceRequestInfoImpl; | |
| 21 | |
| 22 class ResourceLoader : public net::URLRequest::Delegate, | |
|
jam
2012/06/14 01:10:22
nit: add a comment about what this class is used f
| |
| 23 public SSLErrorHandler::Delegate, | |
| 24 public ResourceController, | |
| 25 public base::SupportsWeakPtr<ResourceLoader> { | |
| 26 public: | |
| 27 ResourceLoader(scoped_ptr<net::URLRequest> request, | |
| 28 scoped_ptr<ResourceHandler> handler, | |
| 29 ResourceLoaderDelegate* delegate); | |
| 30 virtual ~ResourceLoader(); | |
| 31 | |
| 32 void StartRequest(); | |
| 33 void CancelRequest(bool from_renderer); | |
| 34 | |
| 35 void ReportUploadProgress(); | |
| 36 | |
| 37 bool is_transferring() const { return is_transferring_; } | |
| 38 void MarkAsTransferring(); | |
| 39 void CompleteTransfer(scoped_ptr<ResourceHandler> new_handler); | |
| 40 | |
| 41 net::URLRequest* request() { return request_.get(); } | |
| 42 ResourceRequestInfoImpl* GetRequestInfo(); | |
| 43 | |
| 44 void ClearLoginDelegate(); | |
| 45 void ClearSSLClientAuthHandler(); | |
| 46 | |
| 47 // IPC message handlers: | |
|
jam
2012/06/14 01:10:22
nit: these message handlers can be private right?
| |
| 48 void OnUploadProgressACK(); | |
| 49 void OnFollowRedirect(bool has_new_first_party_for_cookies, | |
| 50 const GURL& new_first_party_for_cookies); | |
| 51 | |
| 52 // net::URLRequest::Delegate implementation: | |
| 53 virtual void OnReceivedRedirect(net::URLRequest* request, | |
| 54 const GURL& new_url, | |
| 55 bool* defer) OVERRIDE; | |
| 56 virtual void OnAuthRequired(net::URLRequest* request, | |
| 57 net::AuthChallengeInfo* info) OVERRIDE; | |
| 58 virtual void OnCertificateRequested(net::URLRequest* request, | |
| 59 net::SSLCertRequestInfo* info) OVERRIDE; | |
| 60 virtual void OnSSLCertificateError(net::URLRequest* request, | |
| 61 const net::SSLInfo& info, | |
| 62 bool fatal) OVERRIDE; | |
| 63 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; | |
| 64 virtual void OnReadCompleted(net::URLRequest* request, | |
| 65 int bytes_read) OVERRIDE; | |
| 66 | |
| 67 // SSLErrorHandler::Delegate implementation: | |
| 68 virtual void CancelSSLRequest(const GlobalRequestID& id, | |
| 69 int error, | |
| 70 const net::SSLInfo* ssl_info) OVERRIDE; | |
| 71 virtual void ContinueSSLRequest(const GlobalRequestID& id) OVERRIDE; | |
| 72 | |
| 73 // ResourceController implementation: | |
| 74 virtual void Resume() OVERRIDE; | |
| 75 virtual void Cancel() OVERRIDE; | |
| 76 | |
| 77 private: | |
| 78 void StartRequestInternal(); | |
| 79 void CancelRequestInternal(int error, bool from_renderer); | |
| 80 bool CompleteResponseStarted(); | |
| 81 void StartReading(); | |
| 82 bool ReadMore(int* bytes_read); | |
| 83 bool CompleteRead(int* bytes_read); | |
| 84 void ResponseCompleted(); | |
| 85 bool PauseRequestIfNeeded(); | |
| 86 void PauseRequest(bool pause); | |
| 87 void ResumeRequest(); | |
| 88 void CallDidFinishLoading(); | |
| 89 | |
| 90 enum DeferredStage { | |
| 91 DEFERRED_NONE, | |
| 92 DEFERRED_START, | |
| 93 DEFERRED_REDIRECT, | |
| 94 DEFERRED_RESPONSE, | |
| 95 DEFERRED_READ, | |
| 96 DEFERRED_FINISH | |
| 97 }; | |
| 98 DeferredStage deferred_stage_; | |
| 99 | |
| 100 scoped_ptr<net::URLRequest> request_; | |
| 101 scoped_ptr<ResourceHandler> handler_; | |
| 102 ResourceLoaderDelegate* delegate_; | |
| 103 | |
| 104 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; | |
| 105 scoped_refptr<SSLClientAuthHandler> ssl_client_auth_handler_; | |
| 106 | |
| 107 uint64 last_upload_position_; | |
| 108 bool waiting_for_upload_progress_ack_; | |
| 109 base::TimeTicks last_upload_ticks_; | |
| 110 | |
| 111 bool called_on_response_started_; | |
| 112 bool has_started_reading_; | |
| 113 | |
| 114 bool is_paused_; | |
| 115 int pause_count_; | |
| 116 int paused_read_bytes_; | |
| 117 | |
| 118 // Indicates that we are in a state of being transferred to a new downstream | |
| 119 // consumer. We are waiting for a notification to complete the transfer, at | |
| 120 // which point we'll receive a new ResourceHandler. | |
| 121 bool is_transferring_; | |
| 122 | |
| 123 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); | |
| 124 }; | |
| 125 | |
| 126 } // namespace content | |
| 127 | |
| 128 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_LOADER_H_ | |
| OLD | NEW |