| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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" |
| 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_response.h" | 14 #include "webkit/appcache/appcache_response.h" |
| 15 #include "webkit/appcache/appcache_storage.h" | 15 #include "webkit/appcache/appcache_storage.h" |
| 16 | 16 |
| 17 namespace appcache { | 17 namespace appcache { |
| 18 | 18 |
| 19 // A URLRequestJob derivative that knows how to return a response stored | 19 // A net::URLRequestJob derivative that knows how to return a response stored |
| 20 // in the appcache. | 20 // in the appcache. |
| 21 class AppCacheURLRequestJob : public net::URLRequestJob, | 21 class AppCacheURLRequestJob : public net::URLRequestJob, |
| 22 public AppCacheStorage::Delegate { | 22 public AppCacheStorage::Delegate { |
| 23 public: | 23 public: |
| 24 AppCacheURLRequestJob(net::URLRequest* request, AppCacheStorage* storage); | 24 AppCacheURLRequestJob(net::URLRequest* request, AppCacheStorage* storage); |
| 25 virtual ~AppCacheURLRequestJob(); | 25 virtual ~AppCacheURLRequestJob(); |
| 26 | 26 |
| 27 // 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 |
| 28 // 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 |
| 29 // wait indefinitely until one of the deliver methods is called. | 29 // wait indefinitely until one of the deliver methods is called. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 return delivery_type_ == ERROR_DELIVERY; | 48 return delivery_type_ == ERROR_DELIVERY; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Accessors for the info about the appcached response, if any, | 51 // Accessors for the info about the appcached response, if any, |
| 52 // that this job has been instructed to deliver. These are only | 52 // that this job has been instructed to deliver. These are only |
| 53 // valid to call if is_delivering_appcache_response. | 53 // valid to call if is_delivering_appcache_response. |
| 54 const GURL& manifest_url() { return manifest_url_; } | 54 const GURL& manifest_url() { return manifest_url_; } |
| 55 int64 cache_id() { return cache_id_; } | 55 int64 cache_id() { return cache_id_; } |
| 56 const AppCacheEntry& entry() { return entry_; } | 56 const AppCacheEntry& entry() { return entry_; } |
| 57 | 57 |
| 58 // URLRequestJob's Kill method is made public so the users of this | 58 // net::URLRequestJob's Kill method is made public so the users of this |
| 59 // class in the appcache namespace can call it. | 59 // class in the appcache namespace can call it. |
| 60 virtual void Kill(); | 60 virtual void Kill(); |
| 61 | 61 |
| 62 // Returns true if the job has been started by the net library. | 62 // Returns true if the job has been started by the net library. |
| 63 bool has_been_started() const { | 63 bool has_been_started() const { |
| 64 return has_been_started_; | 64 return has_been_started_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Returns true if the job has been killed. | 67 // Returns true if the job has been killed. |
| 68 bool has_been_killed() const { | 68 bool has_been_killed() const { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 97 virtual void OnResponseInfoLoaded( | 97 virtual void OnResponseInfoLoaded( |
| 98 AppCacheResponseInfo* response_info, int64 response_id); | 98 AppCacheResponseInfo* response_info, int64 response_id); |
| 99 | 99 |
| 100 const net::HttpResponseInfo* http_info() const; | 100 const net::HttpResponseInfo* http_info() const; |
| 101 bool is_range_request() const { return range_requested_.IsValid(); } | 101 bool is_range_request() const { return range_requested_.IsValid(); } |
| 102 void SetupRangeResponse(); | 102 void SetupRangeResponse(); |
| 103 | 103 |
| 104 // AppCacheResponseReader completion callback | 104 // AppCacheResponseReader completion callback |
| 105 void OnReadComplete(int result); | 105 void OnReadComplete(int result); |
| 106 | 106 |
| 107 // URLRequestJob methods, see url_request_job.h for doc comments | 107 // net::URLRequestJob methods, see url_request_job.h for doc comments |
| 108 virtual void Start(); | 108 virtual void Start(); |
| 109 virtual net::LoadState GetLoadState() const; | 109 virtual net::LoadState GetLoadState() const; |
| 110 virtual bool GetCharset(std::string* charset); | 110 virtual bool GetCharset(std::string* charset); |
| 111 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 111 virtual void GetResponseInfo(net::HttpResponseInfo* info); |
| 112 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); | 112 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); |
| 113 | 113 |
| 114 // Sets extra request headers for Job types that support request headers. | 114 // Sets extra request headers for Job types that support request headers. |
| 115 // This is how we get informed of range-requests. | 115 // This is how we get informed of range-requests. |
| 116 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers); | 116 virtual void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers); |
| 117 | 117 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 142 net::HttpByteRange range_requested_; | 142 net::HttpByteRange range_requested_; |
| 143 scoped_ptr<net::HttpResponseInfo> range_response_info_; | 143 scoped_ptr<net::HttpResponseInfo> range_response_info_; |
| 144 scoped_ptr<AppCacheResponseReader> reader_; | 144 scoped_ptr<AppCacheResponseReader> reader_; |
| 145 net::CompletionCallbackImpl<AppCacheURLRequestJob> read_callback_; | 145 net::CompletionCallbackImpl<AppCacheURLRequestJob> read_callback_; |
| 146 ScopedRunnableMethodFactory<AppCacheURLRequestJob> method_factory_; | 146 ScopedRunnableMethodFactory<AppCacheURLRequestJob> method_factory_; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace appcache | 149 } // namespace appcache |
| 150 | 150 |
| 151 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 151 #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
| OLD | NEW |