| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WEBKIT_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ |
| 6 #define WEBKIT_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_URL_REQUEST_JOB_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // in the appcache. | 21 // in the appcache. |
| 22 class APPCACHE_EXPORT AppCacheURLRequestJob : public net::URLRequestJob, | 22 class APPCACHE_EXPORT AppCacheURLRequestJob : public net::URLRequestJob, |
| 23 public AppCacheStorage::Delegate { | 23 public AppCacheStorage::Delegate { |
| 24 public: | 24 public: |
| 25 AppCacheURLRequestJob(net::URLRequest* request, AppCacheStorage* storage); | 25 AppCacheURLRequestJob(net::URLRequest* request, AppCacheStorage* storage); |
| 26 virtual ~AppCacheURLRequestJob(); | 26 virtual ~AppCacheURLRequestJob(); |
| 27 | 27 |
| 28 // Informs the job of what response it should deliver. Only one of these | 28 // Informs the job of what response it should deliver. Only one of these |
| 29 // methods should be called, and only once per job. A job will sit idle and | 29 // methods should be called, and only once per job. A job will sit idle and |
| 30 // wait indefinitely until one of the deliver methods is called. | 30 // wait indefinitely until one of the deliver methods is called. |
| 31 void DeliverAppCachedResponse(const GURL& manifest_url, int64 cache_id, | 31 void DeliverAppCachedResponse(const GURL& manifest_url, int64 group_id, |
| 32 const AppCacheEntry& entry, bool is_fallback); | 32 int64 cache_id, const AppCacheEntry& entry, |
| 33 bool is_fallback); |
| 33 void DeliverNetworkResponse(); | 34 void DeliverNetworkResponse(); |
| 34 void DeliverErrorResponse(); | 35 void DeliverErrorResponse(); |
| 35 | 36 |
| 36 bool is_waiting() const { | 37 bool is_waiting() const { |
| 37 return delivery_type_ == AWAITING_DELIVERY_ORDERS; | 38 return delivery_type_ == AWAITING_DELIVERY_ORDERS; |
| 38 } | 39 } |
| 39 | 40 |
| 40 bool is_delivering_appcache_response() const { | 41 bool is_delivering_appcache_response() const { |
| 41 return delivery_type_ == APPCACHED_DELIVERY; | 42 return delivery_type_ == APPCACHED_DELIVERY; |
| 42 } | 43 } |
| 43 | 44 |
| 44 bool is_delivering_network_response() const { | 45 bool is_delivering_network_response() const { |
| 45 return delivery_type_ == NETWORK_DELIVERY; | 46 return delivery_type_ == NETWORK_DELIVERY; |
| 46 } | 47 } |
| 47 | 48 |
| 48 bool is_delivering_error_response() const { | 49 bool is_delivering_error_response() const { |
| 49 return delivery_type_ == ERROR_DELIVERY; | 50 return delivery_type_ == ERROR_DELIVERY; |
| 50 } | 51 } |
| 51 | 52 |
| 52 // Accessors for the info about the appcached response, if any, | 53 // Accessors for the info about the appcached response, if any, |
| 53 // that this job has been instructed to deliver. These are only | 54 // that this job has been instructed to deliver. These are only |
| 54 // valid to call if is_delivering_appcache_response. | 55 // valid to call if is_delivering_appcache_response. |
| 55 const GURL& manifest_url() { return manifest_url_; } | 56 const GURL& manifest_url() const { return manifest_url_; } |
| 56 int64 cache_id() { return cache_id_; } | 57 int64 group_id() const { return group_id_; } |
| 57 const AppCacheEntry& entry() { return entry_; } | 58 int64 cache_id() const { return cache_id_; } |
| 59 const AppCacheEntry& entry() const { return entry_; } |
| 58 | 60 |
| 59 // net::URLRequestJob's Kill method is made public so the users of this | 61 // net::URLRequestJob's Kill method is made public so the users of this |
| 60 // class in the appcache namespace can call it. | 62 // class in the appcache namespace can call it. |
| 61 virtual void Kill(); | 63 virtual void Kill(); |
| 62 | 64 |
| 63 // Returns true if the job has been started by the net library. | 65 // Returns true if the job has been started by the net library. |
| 64 bool has_been_started() const { | 66 bool has_been_started() const { |
| 65 return has_been_started_; | 67 return has_been_started_; |
| 66 } | 68 } |
| 67 | 69 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 120 |
| 119 // FilterContext methods | 121 // FilterContext methods |
| 120 virtual bool GetMimeType(std::string* mime_type) const; | 122 virtual bool GetMimeType(std::string* mime_type) const; |
| 121 virtual int GetResponseCode() const; | 123 virtual int GetResponseCode() const; |
| 122 | 124 |
| 123 AppCacheStorage* storage_; | 125 AppCacheStorage* storage_; |
| 124 bool has_been_started_; | 126 bool has_been_started_; |
| 125 bool has_been_killed_; | 127 bool has_been_killed_; |
| 126 DeliveryType delivery_type_; | 128 DeliveryType delivery_type_; |
| 127 GURL manifest_url_; | 129 GURL manifest_url_; |
| 130 int64 group_id_; |
| 128 int64 cache_id_; | 131 int64 cache_id_; |
| 129 AppCacheEntry entry_; | 132 AppCacheEntry entry_; |
| 130 bool is_fallback_; | 133 bool is_fallback_; |
| 131 bool cache_entry_not_found_; | 134 bool cache_entry_not_found_; |
| 132 scoped_refptr<AppCacheResponseInfo> info_; | 135 scoped_refptr<AppCacheResponseInfo> info_; |
| 133 net::HttpByteRange range_requested_; | 136 net::HttpByteRange range_requested_; |
| 134 scoped_ptr<net::HttpResponseInfo> range_response_info_; | 137 scoped_ptr<net::HttpResponseInfo> range_response_info_; |
| 135 scoped_ptr<AppCacheResponseReader> reader_; | 138 scoped_ptr<AppCacheResponseReader> reader_; |
| 136 net::OldCompletionCallbackImpl<AppCacheURLRequestJob> read_callback_; | 139 net::OldCompletionCallbackImpl<AppCacheURLRequestJob> read_callback_; |
| 137 ScopedRunnableMethodFactory<AppCacheURLRequestJob> method_factory_; | 140 ScopedRunnableMethodFactory<AppCacheURLRequestJob> method_factory_; |
| 138 }; | 141 }; |
| 139 | 142 |
| 140 } // namespace appcache | 143 } // namespace appcache |
| 141 | 144 |
| 142 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 145 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
| OLD | NEW |