| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 6 #define CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/browser/loader/resource_handler.h" | 10 #include "content/browser/loader/resource_handler.h" |
| 11 #include "content/browser/loader/resource_scheduler.h" |
| 11 #include "content/browser/ssl/ssl_error_handler.h" | 12 #include "content/browser/ssl/ssl_error_handler.h" |
| 12 #include "content/public/browser/resource_controller.h" | 13 #include "content/public/browser/resource_controller.h" |
| 13 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 class ResourceDispatcherHostLoginDelegate; | 17 class ResourceDispatcherHostLoginDelegate; |
| 17 class ResourceLoaderDelegate; | 18 class ResourceLoaderDelegate; |
| 18 class ResourceRequestInfoImpl; | 19 class ResourceRequestInfoImpl; |
| 19 class SSLClientAuthHandler; | 20 class SSLClientAuthHandler; |
| 20 | 21 |
| 21 // This class is responsible for driving the URLRequest (i.e., calling Start, | 22 // This class is responsible for driving the URLRequest (i.e., calling Start, |
| 22 // Read, and servicing events). It has a ResourceHandler, which is typically a | 23 // Read, and servicing events). It has a ResourceHandler, which is typically a |
| 23 // chain of ResourceHandlers, and is the ResourceController for its handler. | 24 // chain of ResourceHandlers, and is the ResourceController for its handler. |
| 24 class ResourceLoader : public net::URLRequest::Delegate, | 25 class ResourceLoader : public net::URLRequest::Delegate, |
| 25 public SSLErrorHandler::Delegate, | 26 public SSLErrorHandler::Delegate, |
| 26 public ResourceController { | 27 public ResourceController, |
| 28 public ResourceScheduler::Loadable { |
| 27 public: | 29 public: |
| 28 ResourceLoader(scoped_ptr<net::URLRequest> request, | 30 CONTENT_EXPORT ResourceLoader(scoped_ptr<net::URLRequest> request, |
| 29 scoped_ptr<ResourceHandler> handler, | 31 scoped_ptr<ResourceHandler> handler, |
| 30 ResourceLoaderDelegate* delegate); | 32 ResourceLoaderDelegate* delegate); |
| 31 virtual ~ResourceLoader(); | 33 virtual ~ResourceLoader(); |
| 32 | 34 |
| 33 void StartRequest(); | 35 void ScheduleRequest(ResourceScheduler* scheduler); |
| 34 void CancelRequest(bool from_renderer); | 36 void CancelRequest(bool from_renderer); |
| 35 | 37 |
| 36 void ReportUploadProgress(); | 38 void ReportUploadProgress(); |
| 37 | 39 |
| 38 bool is_transferring() const { return is_transferring_; } | 40 bool is_transferring() const { return is_transferring_; } |
| 39 void MarkAsTransferring(); | 41 void MarkAsTransferring(); |
| 40 void WillCompleteTransfer(); | 42 void WillCompleteTransfer(); |
| 41 void CompleteTransfer(scoped_ptr<ResourceHandler> new_handler); | 43 void CompleteTransfer(scoped_ptr<ResourceHandler> new_handler); |
| 42 | 44 |
| 43 net::URLRequest* request() { return request_.get(); } | 45 net::URLRequest* request() { return request_.get(); } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 70 int error, | 72 int error, |
| 71 const net::SSLInfo* ssl_info) OVERRIDE; | 73 const net::SSLInfo* ssl_info) OVERRIDE; |
| 72 virtual void ContinueSSLRequest(const GlobalRequestID& id) OVERRIDE; | 74 virtual void ContinueSSLRequest(const GlobalRequestID& id) OVERRIDE; |
| 73 | 75 |
| 74 // ResourceController implementation: | 76 // ResourceController implementation: |
| 75 virtual void Resume() OVERRIDE; | 77 virtual void Resume() OVERRIDE; |
| 76 virtual void Cancel() OVERRIDE; | 78 virtual void Cancel() OVERRIDE; |
| 77 virtual void CancelAndIgnore() OVERRIDE; | 79 virtual void CancelAndIgnore() OVERRIDE; |
| 78 virtual void CancelWithError(int error_code) OVERRIDE; | 80 virtual void CancelWithError(int error_code) OVERRIDE; |
| 79 | 81 |
| 82 // ResourceScheduler::Loadable implementation: |
| 83 virtual void StartRequest() OVERRIDE; |
| 84 virtual const net::URLRequest* url_request() OVERRIDE; |
| 85 |
| 80 void StartRequestInternal(); | 86 void StartRequestInternal(); |
| 81 void CancelRequestInternal(int error, bool from_renderer); | 87 void CancelRequestInternal(int error, bool from_renderer); |
| 82 void CompleteResponseStarted(); | 88 void CompleteResponseStarted(); |
| 83 void StartReading(bool is_continuation); | 89 void StartReading(bool is_continuation); |
| 84 void ResumeReading(); | 90 void ResumeReading(); |
| 85 void ReadMore(int* bytes_read); | 91 void ReadMore(int* bytes_read); |
| 86 void CompleteRead(int bytes_read); | 92 void CompleteRead(int bytes_read); |
| 87 void ResponseCompleted(); | 93 void ResponseCompleted(); |
| 88 void CallDidFinishLoading(); | 94 void CallDidFinishLoading(); |
| 89 | 95 |
| 90 bool is_deferred() const { return deferred_stage_ != DEFERRED_NONE; } | 96 bool is_deferred() const { return deferred_stage_ != DEFERRED_NONE; } |
| 91 | 97 |
| 92 enum DeferredStage { | 98 enum DeferredStage { |
| 93 DEFERRED_NONE, | 99 DEFERRED_NONE, |
| 94 DEFERRED_START, | 100 DEFERRED_START, |
| 95 DEFERRED_REDIRECT, | 101 DEFERRED_REDIRECT, |
| 96 DEFERRED_READ, | 102 DEFERRED_READ, |
| 97 DEFERRED_FINISH | 103 DEFERRED_FINISH |
| 98 }; | 104 }; |
| 99 DeferredStage deferred_stage_; | 105 DeferredStage deferred_stage_; |
| 100 | 106 |
| 101 scoped_ptr<net::URLRequest> request_; | 107 scoped_ptr<net::URLRequest> request_; |
| 102 scoped_ptr<ResourceHandler> handler_; | 108 scoped_ptr<ResourceHandler> handler_; |
| 103 ResourceLoaderDelegate* delegate_; | 109 ResourceLoaderDelegate* delegate_; |
| 110 scoped_ptr<ResourceScheduler::LoadHandle> load_handle_; |
| 104 | 111 |
| 105 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; | 112 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; |
| 106 scoped_refptr<SSLClientAuthHandler> ssl_client_auth_handler_; | 113 scoped_refptr<SSLClientAuthHandler> ssl_client_auth_handler_; |
| 107 | 114 |
| 108 uint64 last_upload_position_; | 115 uint64 last_upload_position_; |
| 109 bool waiting_for_upload_progress_ack_; | 116 bool waiting_for_upload_progress_ack_; |
| 110 base::TimeTicks last_upload_ticks_; | 117 base::TimeTicks last_upload_ticks_; |
| 111 | 118 |
| 112 // Indicates that we are in a state of being transferred to a new downstream | 119 // Indicates that we are in a state of being transferred to a new downstream |
| 113 // consumer. We are waiting for a notification to complete the transfer, at | 120 // consumer. We are waiting for a notification to complete the transfer, at |
| 114 // which point we'll receive a new ResourceHandler. | 121 // which point we'll receive a new ResourceHandler. |
| 115 bool is_transferring_; | 122 bool is_transferring_; |
| 116 | 123 |
| 117 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; | 124 base::WeakPtrFactory<ResourceLoader> weak_ptr_factory_; |
| 118 | 125 |
| 119 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); | 126 DISALLOW_COPY_AND_ASSIGN(ResourceLoader); |
| 120 }; | 127 }; |
| 121 | 128 |
| 122 } // namespace content | 129 } // namespace content |
| 123 | 130 |
| 124 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ | 131 #endif // CONTENT_BROWSER_LOADER_RESOURCE_LOADER_H_ |
| OLD | NEW |