| 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_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "base/callback.h" | 12 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 12 #include "content/browser/appcache/appcache_entry.h" | 14 #include "content/browser/appcache/appcache_entry.h" |
| 13 #include "content/browser/appcache/appcache_executable_handler.h" | 15 #include "content/browser/appcache/appcache_executable_handler.h" |
| 14 #include "content/browser/appcache/appcache_response.h" | 16 #include "content/browser/appcache/appcache_response.h" |
| 15 #include "content/browser/appcache/appcache_storage.h" | 17 #include "content/browser/appcache/appcache_storage.h" |
| 16 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 17 #include "net/http/http_byte_range.h" | 19 #include "net/http/http_byte_range.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 42 AppCacheStorage* storage, | 44 AppCacheStorage* storage, |
| 43 AppCacheHost* host, | 45 AppCacheHost* host, |
| 44 bool is_main_resource, | 46 bool is_main_resource, |
| 45 const OnPrepareToRestartCallback& restart_callback_); | 47 const OnPrepareToRestartCallback& restart_callback_); |
| 46 | 48 |
| 47 ~AppCacheURLRequestJob() override; | 49 ~AppCacheURLRequestJob() override; |
| 48 | 50 |
| 49 // Informs the job of what response it should deliver. Only one of these | 51 // Informs the job of what response it should deliver. Only one of these |
| 50 // methods should be called, and only once per job. A job will sit idle and | 52 // methods should be called, and only once per job. A job will sit idle and |
| 51 // wait indefinitely until one of the deliver methods is called. | 53 // wait indefinitely until one of the deliver methods is called. |
| 52 void DeliverAppCachedResponse(const GURL& manifest_url, int64 group_id, | 54 void DeliverAppCachedResponse(const GURL& manifest_url, |
| 53 int64 cache_id, const AppCacheEntry& entry, | 55 int64_t group_id, |
| 56 int64_t cache_id, |
| 57 const AppCacheEntry& entry, |
| 54 bool is_fallback); | 58 bool is_fallback); |
| 55 void DeliverNetworkResponse(); | 59 void DeliverNetworkResponse(); |
| 56 void DeliverErrorResponse(); | 60 void DeliverErrorResponse(); |
| 57 | 61 |
| 58 bool is_waiting() const { | 62 bool is_waiting() const { |
| 59 return delivery_type_ == AWAITING_DELIVERY_ORDERS; | 63 return delivery_type_ == AWAITING_DELIVERY_ORDERS; |
| 60 } | 64 } |
| 61 | 65 |
| 62 bool is_delivering_appcache_response() const { | 66 bool is_delivering_appcache_response() const { |
| 63 return delivery_type_ == APPCACHED_DELIVERY; | 67 return delivery_type_ == APPCACHED_DELIVERY; |
| 64 } | 68 } |
| 65 | 69 |
| 66 bool is_delivering_network_response() const { | 70 bool is_delivering_network_response() const { |
| 67 return delivery_type_ == NETWORK_DELIVERY; | 71 return delivery_type_ == NETWORK_DELIVERY; |
| 68 } | 72 } |
| 69 | 73 |
| 70 bool is_delivering_error_response() const { | 74 bool is_delivering_error_response() const { |
| 71 return delivery_type_ == ERROR_DELIVERY; | 75 return delivery_type_ == ERROR_DELIVERY; |
| 72 } | 76 } |
| 73 | 77 |
| 74 // Accessors for the info about the appcached response, if any, | 78 // Accessors for the info about the appcached response, if any, |
| 75 // that this job has been instructed to deliver. These are only | 79 // that this job has been instructed to deliver. These are only |
| 76 // valid to call if is_delivering_appcache_response. | 80 // valid to call if is_delivering_appcache_response. |
| 77 const GURL& manifest_url() const { return manifest_url_; } | 81 const GURL& manifest_url() const { return manifest_url_; } |
| 78 int64 group_id() const { return group_id_; } | 82 int64_t group_id() const { return group_id_; } |
| 79 int64 cache_id() const { return cache_id_; } | 83 int64_t cache_id() const { return cache_id_; } |
| 80 const AppCacheEntry& entry() const { return entry_; } | 84 const AppCacheEntry& entry() const { return entry_; } |
| 81 | 85 |
| 82 // net::URLRequestJob's Kill method is made public so the users of this | 86 // net::URLRequestJob's Kill method is made public so the users of this |
| 83 // class in the appcache namespace can call it. | 87 // class in the appcache namespace can call it. |
| 84 void Kill() override; | 88 void Kill() override; |
| 85 | 89 |
| 86 // Returns true if the job has been started by the net library. | 90 // Returns true if the job has been started by the net library. |
| 87 bool has_been_started() const { | 91 bool has_been_started() const { |
| 88 return has_been_started_; | 92 return has_been_started_; |
| 89 } | 93 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // For executable response handling. | 129 // For executable response handling. |
| 126 void BeginExecutableHandlerDelivery(); | 130 void BeginExecutableHandlerDelivery(); |
| 127 void OnExecutableSourceLoaded(int result); | 131 void OnExecutableSourceLoaded(int result); |
| 128 void InvokeExecutableHandler(AppCacheExecutableHandler* handler); | 132 void InvokeExecutableHandler(AppCacheExecutableHandler* handler); |
| 129 void OnExecutableResponseCallback( | 133 void OnExecutableResponseCallback( |
| 130 const AppCacheExecutableHandler::Response& response); | 134 const AppCacheExecutableHandler::Response& response); |
| 131 void BeginErrorDelivery(const char* message); | 135 void BeginErrorDelivery(const char* message); |
| 132 | 136 |
| 133 // AppCacheStorage::Delegate methods | 137 // AppCacheStorage::Delegate methods |
| 134 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, | 138 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, |
| 135 int64 response_id) override; | 139 int64_t response_id) override; |
| 136 void OnCacheLoaded(AppCache* cache, int64 cache_id) override; | 140 void OnCacheLoaded(AppCache* cache, int64_t cache_id) override; |
| 137 | 141 |
| 138 const net::HttpResponseInfo* http_info() const; | 142 const net::HttpResponseInfo* http_info() const; |
| 139 bool is_range_request() const { return range_requested_.IsValid(); } | 143 bool is_range_request() const { return range_requested_.IsValid(); } |
| 140 void SetupRangeResponse(); | 144 void SetupRangeResponse(); |
| 141 | 145 |
| 142 // AppCacheResponseReader completion callback | 146 // AppCacheResponseReader completion callback |
| 143 void OnReadComplete(int result); | 147 void OnReadComplete(int result); |
| 144 | 148 |
| 145 // net::URLRequestJob methods, see url_request_job.h for doc comments | 149 // net::URLRequestJob methods, see url_request_job.h for doc comments |
| 146 void Start() override; | 150 void Start() override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 161 // net::URLRequestJob::NotifyRestartRequired. | 165 // net::URLRequestJob::NotifyRestartRequired. |
| 162 void NotifyRestartRequired(); | 166 void NotifyRestartRequired(); |
| 163 | 167 |
| 164 AppCacheHost* host_; | 168 AppCacheHost* host_; |
| 165 AppCacheStorage* storage_; | 169 AppCacheStorage* storage_; |
| 166 base::TimeTicks start_time_tick_; | 170 base::TimeTicks start_time_tick_; |
| 167 bool has_been_started_; | 171 bool has_been_started_; |
| 168 bool has_been_killed_; | 172 bool has_been_killed_; |
| 169 DeliveryType delivery_type_; | 173 DeliveryType delivery_type_; |
| 170 GURL manifest_url_; | 174 GURL manifest_url_; |
| 171 int64 group_id_; | 175 int64_t group_id_; |
| 172 int64 cache_id_; | 176 int64_t cache_id_; |
| 173 AppCacheEntry entry_; | 177 AppCacheEntry entry_; |
| 174 bool is_fallback_; | 178 bool is_fallback_; |
| 175 bool is_main_resource_; // Used for histogram logging. | 179 bool is_main_resource_; // Used for histogram logging. |
| 176 bool cache_entry_not_found_; | 180 bool cache_entry_not_found_; |
| 177 scoped_refptr<AppCacheResponseInfo> info_; | 181 scoped_refptr<AppCacheResponseInfo> info_; |
| 178 scoped_refptr<net::GrowableIOBuffer> handler_source_buffer_; | 182 scoped_refptr<net::GrowableIOBuffer> handler_source_buffer_; |
| 179 scoped_ptr<AppCacheResponseReader> handler_source_reader_; | 183 scoped_ptr<AppCacheResponseReader> handler_source_reader_; |
| 180 net::HttpByteRange range_requested_; | 184 net::HttpByteRange range_requested_; |
| 181 scoped_ptr<net::HttpResponseInfo> range_response_info_; | 185 scoped_ptr<net::HttpResponseInfo> range_response_info_; |
| 182 scoped_ptr<AppCacheResponseReader> reader_; | 186 scoped_ptr<AppCacheResponseReader> reader_; |
| 183 scoped_refptr<AppCache> cache_; | 187 scoped_refptr<AppCache> cache_; |
| 184 scoped_refptr<AppCacheGroup> group_; | 188 scoped_refptr<AppCacheGroup> group_; |
| 185 const OnPrepareToRestartCallback on_prepare_to_restart_callback_; | 189 const OnPrepareToRestartCallback on_prepare_to_restart_callback_; |
| 186 base::WeakPtrFactory<AppCacheURLRequestJob> weak_factory_; | 190 base::WeakPtrFactory<AppCacheURLRequestJob> weak_factory_; |
| 187 }; | 191 }; |
| 188 | 192 |
| 189 } // namespace content | 193 } // namespace content |
| 190 | 194 |
| 191 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ | 195 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ |
| OLD | NEW |