Chromium Code Reviews| Index: content/browser/renderer_host/resource_loader.h |
| =================================================================== |
| --- content/browser/renderer_host/resource_loader.h (revision 0) |
| +++ content/browser/renderer_host/resource_loader.h (revision 0) |
| @@ -0,0 +1,128 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_LOADER_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_LOADER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "content/browser/renderer_host/resource_handler.h" |
| +#include "content/browser/ssl/ssl_error_handler.h" |
| +#include "content/public/browser/resource_controller.h" |
| +#include "net/url_request/url_request.h" |
| + |
| +class SSLClientAuthHandler; |
| + |
| +namespace content { |
| +class ResourceDispatcherHostLoginDelegate; |
| +class ResourceLoaderDelegate; |
| +class ResourceRequestInfoImpl; |
| + |
| +class ResourceLoader : public net::URLRequest::Delegate, |
|
jam
2012/06/14 01:10:22
nit: add a comment about what this class is used f
|
| + public SSLErrorHandler::Delegate, |
| + public ResourceController, |
| + public base::SupportsWeakPtr<ResourceLoader> { |
| + public: |
| + ResourceLoader(scoped_ptr<net::URLRequest> request, |
| + scoped_ptr<ResourceHandler> handler, |
| + ResourceLoaderDelegate* delegate); |
| + virtual ~ResourceLoader(); |
| + |
| + void StartRequest(); |
| + void CancelRequest(bool from_renderer); |
| + |
| + void ReportUploadProgress(); |
| + |
| + bool is_transferring() const { return is_transferring_; } |
| + void MarkAsTransferring(); |
| + void CompleteTransfer(scoped_ptr<ResourceHandler> new_handler); |
| + |
| + net::URLRequest* request() { return request_.get(); } |
| + ResourceRequestInfoImpl* GetRequestInfo(); |
| + |
| + void ClearLoginDelegate(); |
| + void ClearSSLClientAuthHandler(); |
| + |
| + // IPC message handlers: |
|
jam
2012/06/14 01:10:22
nit: these message handlers can be private right?
|
| + void OnUploadProgressACK(); |
| + void OnFollowRedirect(bool has_new_first_party_for_cookies, |
| + const GURL& new_first_party_for_cookies); |
| + |
| + // net::URLRequest::Delegate implementation: |
| + virtual void OnReceivedRedirect(net::URLRequest* request, |
| + const GURL& new_url, |
| + bool* defer) OVERRIDE; |
| + virtual void OnAuthRequired(net::URLRequest* request, |
| + net::AuthChallengeInfo* info) OVERRIDE; |
| + virtual void OnCertificateRequested(net::URLRequest* request, |
| + net::SSLCertRequestInfo* info) OVERRIDE; |
| + virtual void OnSSLCertificateError(net::URLRequest* request, |
| + const net::SSLInfo& info, |
| + bool fatal) OVERRIDE; |
| + virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE; |
| + virtual void OnReadCompleted(net::URLRequest* request, |
| + int bytes_read) OVERRIDE; |
| + |
| + // SSLErrorHandler::Delegate implementation: |
| + virtual void CancelSSLRequest(const GlobalRequestID& id, |
| + int error, |
| + const net::SSLInfo* ssl_info) OVERRIDE; |
| + virtual void ContinueSSLRequest(const GlobalRequestID& id) OVERRIDE; |
| + |
| + // ResourceController implementation: |
| + virtual void Resume() OVERRIDE; |
| + virtual void Cancel() OVERRIDE; |
| + |
| + private: |
| + void StartRequestInternal(); |
| + void CancelRequestInternal(int error, bool from_renderer); |
| + bool CompleteResponseStarted(); |
| + void StartReading(); |
| + bool ReadMore(int* bytes_read); |
| + bool CompleteRead(int* bytes_read); |
| + void ResponseCompleted(); |
| + bool PauseRequestIfNeeded(); |
| + void PauseRequest(bool pause); |
| + void ResumeRequest(); |
| + void CallDidFinishLoading(); |
| + |
| + enum DeferredStage { |
| + DEFERRED_NONE, |
| + DEFERRED_START, |
| + DEFERRED_REDIRECT, |
| + DEFERRED_RESPONSE, |
| + DEFERRED_READ, |
| + DEFERRED_FINISH |
| + }; |
| + DeferredStage deferred_stage_; |
| + |
| + scoped_ptr<net::URLRequest> request_; |
| + scoped_ptr<ResourceHandler> handler_; |
| + ResourceLoaderDelegate* delegate_; |
| + |
| + scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; |
| + scoped_refptr<SSLClientAuthHandler> ssl_client_auth_handler_; |
| + |
| + uint64 last_upload_position_; |
| + bool waiting_for_upload_progress_ack_; |
| + base::TimeTicks last_upload_ticks_; |
| + |
| + bool called_on_response_started_; |
| + bool has_started_reading_; |
| + |
| + bool is_paused_; |
| + int pause_count_; |
| + int paused_read_bytes_; |
| + |
| + // Indicates that we are in a state of being transferred to a new downstream |
| + // consumer. We are waiting for a notification to complete the transfer, at |
| + // which point we'll receive a new ResourceHandler. |
| + bool is_transferring_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_LOADER_H_ |