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/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "net/http/http_byte_range.h" | 11 #include "net/http/http_byte_range.h" |
12 #include "net/url_request/url_request_job.h" | 12 #include "net/url_request/url_request_job.h" |
13 #include "webkit/appcache/appcache_entry.h" | 13 #include "webkit/appcache/appcache_entry.h" |
14 #include "webkit/appcache/appcache_export.h" | 14 #include "webkit/appcache/appcache_export.h" |
15 #include "webkit/appcache/appcache_response.h" | 15 #include "webkit/appcache/appcache_response.h" |
16 #include "webkit/appcache/appcache_storage.h" | 16 #include "webkit/appcache/appcache_storage.h" |
17 | 17 |
18 namespace appcache { | 18 namespace appcache { |
19 | 19 |
20 // A net::URLRequestJob derivative that knows how to return a response stored | 20 // A net::URLRequestJob derivative that knows how to return a response stored |
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(); | |
27 | 26 |
28 // Informs the job of what response it should deliver. Only one of these | 27 // 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 | 28 // 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. | 29 // wait indefinitely until one of the deliver methods is called. |
31 void DeliverAppCachedResponse(const GURL& manifest_url, int64 group_id, | 30 void DeliverAppCachedResponse(const GURL& manifest_url, int64 group_id, |
32 int64 cache_id, const AppCacheEntry& entry, | 31 int64 cache_id, const AppCacheEntry& entry, |
33 bool is_fallback); | 32 bool is_fallback); |
34 void DeliverNetworkResponse(); | 33 void DeliverNetworkResponse(); |
35 void DeliverErrorResponse(); | 34 void DeliverErrorResponse(); |
36 | 35 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Returns true if the job has been killed. | 69 // Returns true if the job has been killed. |
71 bool has_been_killed() const { | 70 bool has_been_killed() const { |
72 return has_been_killed_; | 71 return has_been_killed_; |
73 } | 72 } |
74 | 73 |
75 // Returns true if the cache entry was not found in the disk cache. | 74 // Returns true if the cache entry was not found in the disk cache. |
76 bool cache_entry_not_found() const { | 75 bool cache_entry_not_found() const { |
77 return cache_entry_not_found_; | 76 return cache_entry_not_found_; |
78 } | 77 } |
79 | 78 |
| 79 protected: |
| 80 virtual ~AppCacheURLRequestJob(); |
| 81 |
80 private: | 82 private: |
81 friend class AppCacheRequestHandlerTest; | 83 friend class AppCacheRequestHandlerTest; |
82 friend class AppCacheURLRequestJobTest; | 84 friend class AppCacheURLRequestJobTest; |
83 | 85 |
84 enum DeliveryType { | 86 enum DeliveryType { |
85 AWAITING_DELIVERY_ORDERS, | 87 AWAITING_DELIVERY_ORDERS, |
86 APPCACHED_DELIVERY, | 88 APPCACHED_DELIVERY, |
87 NETWORK_DELIVERY, | 89 NETWORK_DELIVERY, |
88 ERROR_DELIVERY | 90 ERROR_DELIVERY |
89 }; | 91 }; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 scoped_refptr<AppCacheResponseInfo> info_; | 140 scoped_refptr<AppCacheResponseInfo> info_; |
139 net::HttpByteRange range_requested_; | 141 net::HttpByteRange range_requested_; |
140 scoped_ptr<net::HttpResponseInfo> range_response_info_; | 142 scoped_ptr<net::HttpResponseInfo> range_response_info_; |
141 scoped_ptr<AppCacheResponseReader> reader_; | 143 scoped_ptr<AppCacheResponseReader> reader_; |
142 base::WeakPtrFactory<AppCacheURLRequestJob> weak_factory_; | 144 base::WeakPtrFactory<AppCacheURLRequestJob> weak_factory_; |
143 }; | 145 }; |
144 | 146 |
145 } // namespace appcache | 147 } // namespace appcache |
146 | 148 |
147 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 149 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
OLD | NEW |