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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // Accessors for the info about the appcached response, if any, | 65 // Accessors for the info about the appcached response, if any, |
66 // that this job has been instructed to deliver. These are only | 66 // that this job has been instructed to deliver. These are only |
67 // valid to call if is_delivering_appcache_response. | 67 // valid to call if is_delivering_appcache_response. |
68 const GURL& manifest_url() const { return manifest_url_; } | 68 const GURL& manifest_url() const { return manifest_url_; } |
69 int64 group_id() const { return group_id_; } | 69 int64 group_id() const { return group_id_; } |
70 int64 cache_id() const { return cache_id_; } | 70 int64 cache_id() const { return cache_id_; } |
71 const AppCacheEntry& entry() const { return entry_; } | 71 const AppCacheEntry& entry() const { return entry_; } |
72 | 72 |
73 // net::URLRequestJob's Kill method is made public so the users of this | 73 // net::URLRequestJob's Kill method is made public so the users of this |
74 // class in the appcache namespace can call it. | 74 // class in the appcache namespace can call it. |
75 virtual void Kill() override; | 75 void Kill() override; |
76 | 76 |
77 // Returns true if the job has been started by the net library. | 77 // Returns true if the job has been started by the net library. |
78 bool has_been_started() const { | 78 bool has_been_started() const { |
79 return has_been_started_; | 79 return has_been_started_; |
80 } | 80 } |
81 | 81 |
82 // Returns true if the job has been killed. | 82 // Returns true if the job has been killed. |
83 bool has_been_killed() const { | 83 bool has_been_killed() const { |
84 return has_been_killed_; | 84 return has_been_killed_; |
85 } | 85 } |
86 | 86 |
87 // Returns true if the cache entry was not found in the disk cache. | 87 // Returns true if the cache entry was not found in the disk cache. |
88 bool cache_entry_not_found() const { | 88 bool cache_entry_not_found() const { |
89 return cache_entry_not_found_; | 89 return cache_entry_not_found_; |
90 } | 90 } |
91 | 91 |
92 protected: | 92 protected: |
93 virtual ~AppCacheURLRequestJob(); | 93 ~AppCacheURLRequestJob() override; |
94 | 94 |
95 private: | 95 private: |
96 friend class content::AppCacheRequestHandlerTest; | 96 friend class content::AppCacheRequestHandlerTest; |
97 friend class content::AppCacheURLRequestJobTest; | 97 friend class content::AppCacheURLRequestJobTest; |
98 | 98 |
99 enum DeliveryType { | 99 enum DeliveryType { |
100 AWAITING_DELIVERY_ORDERS, | 100 AWAITING_DELIVERY_ORDERS, |
101 APPCACHED_DELIVERY, | 101 APPCACHED_DELIVERY, |
102 NETWORK_DELIVERY, | 102 NETWORK_DELIVERY, |
103 ERROR_DELIVERY | 103 ERROR_DELIVERY |
104 }; | 104 }; |
105 | 105 |
106 // Returns true if one of the Deliver methods has been called. | 106 // Returns true if one of the Deliver methods has been called. |
107 bool has_delivery_orders() const { | 107 bool has_delivery_orders() const { |
108 return !is_waiting(); | 108 return !is_waiting(); |
109 } | 109 } |
110 | 110 |
111 void MaybeBeginDelivery(); | 111 void MaybeBeginDelivery(); |
112 void BeginDelivery(); | 112 void BeginDelivery(); |
113 | 113 |
114 // For executable response handling. | 114 // For executable response handling. |
115 void BeginExecutableHandlerDelivery(); | 115 void BeginExecutableHandlerDelivery(); |
116 void OnExecutableSourceLoaded(int result); | 116 void OnExecutableSourceLoaded(int result); |
117 void InvokeExecutableHandler(AppCacheExecutableHandler* handler); | 117 void InvokeExecutableHandler(AppCacheExecutableHandler* handler); |
118 void OnExecutableResponseCallback( | 118 void OnExecutableResponseCallback( |
119 const AppCacheExecutableHandler::Response& response); | 119 const AppCacheExecutableHandler::Response& response); |
120 void BeginErrorDelivery(const char* message); | 120 void BeginErrorDelivery(const char* message); |
121 | 121 |
122 // AppCacheStorage::Delegate methods | 122 // AppCacheStorage::Delegate methods |
123 virtual void OnResponseInfoLoaded( | 123 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, |
124 AppCacheResponseInfo* response_info, int64 response_id) override; | 124 int64 response_id) override; |
125 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) override; | 125 void OnCacheLoaded(AppCache* cache, int64 cache_id) override; |
126 | 126 |
127 const net::HttpResponseInfo* http_info() const; | 127 const net::HttpResponseInfo* http_info() const; |
128 bool is_range_request() const { return range_requested_.IsValid(); } | 128 bool is_range_request() const { return range_requested_.IsValid(); } |
129 void SetupRangeResponse(); | 129 void SetupRangeResponse(); |
130 | 130 |
131 // AppCacheResponseReader completion callback | 131 // AppCacheResponseReader completion callback |
132 void OnReadComplete(int result); | 132 void OnReadComplete(int result); |
133 | 133 |
134 // net::URLRequestJob methods, see url_request_job.h for doc comments | 134 // net::URLRequestJob methods, see url_request_job.h for doc comments |
135 virtual void Start() override; | 135 void Start() override; |
136 virtual net::LoadState GetLoadState() const override; | 136 net::LoadState GetLoadState() const override; |
137 virtual bool GetCharset(std::string* charset) override; | 137 bool GetCharset(std::string* charset) override; |
138 virtual void GetResponseInfo(net::HttpResponseInfo* info) override; | 138 void GetResponseInfo(net::HttpResponseInfo* info) override; |
139 virtual bool ReadRawData(net::IOBuffer* buf, | 139 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override; |
140 int buf_size, | |
141 int *bytes_read) override; | |
142 | 140 |
143 // Sets extra request headers for Job types that support request headers. | 141 // Sets extra request headers for Job types that support request headers. |
144 // This is how we get informed of range-requests. | 142 // This is how we get informed of range-requests. |
145 virtual void SetExtraRequestHeaders( | 143 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; |
146 const net::HttpRequestHeaders& headers) override; | |
147 | 144 |
148 // FilterContext methods | 145 // FilterContext methods |
149 virtual bool GetMimeType(std::string* mime_type) const override; | 146 bool GetMimeType(std::string* mime_type) const override; |
150 virtual int GetResponseCode() const override; | 147 int GetResponseCode() const override; |
151 | 148 |
152 AppCacheHost* host_; | 149 AppCacheHost* host_; |
153 AppCacheStorage* storage_; | 150 AppCacheStorage* storage_; |
154 base::TimeTicks start_time_tick_; | 151 base::TimeTicks start_time_tick_; |
155 bool has_been_started_; | 152 bool has_been_started_; |
156 bool has_been_killed_; | 153 bool has_been_killed_; |
157 DeliveryType delivery_type_; | 154 DeliveryType delivery_type_; |
158 GURL manifest_url_; | 155 GURL manifest_url_; |
159 int64 group_id_; | 156 int64 group_id_; |
160 int64 cache_id_; | 157 int64 cache_id_; |
161 AppCacheEntry entry_; | 158 AppCacheEntry entry_; |
162 bool is_fallback_; | 159 bool is_fallback_; |
163 bool is_main_resource_; // Used for histogram logging. | 160 bool is_main_resource_; // Used for histogram logging. |
164 bool cache_entry_not_found_; | 161 bool cache_entry_not_found_; |
165 scoped_refptr<AppCacheResponseInfo> info_; | 162 scoped_refptr<AppCacheResponseInfo> info_; |
166 scoped_refptr<net::GrowableIOBuffer> handler_source_buffer_; | 163 scoped_refptr<net::GrowableIOBuffer> handler_source_buffer_; |
167 scoped_ptr<AppCacheResponseReader> handler_source_reader_; | 164 scoped_ptr<AppCacheResponseReader> handler_source_reader_; |
168 net::HttpByteRange range_requested_; | 165 net::HttpByteRange range_requested_; |
169 scoped_ptr<net::HttpResponseInfo> range_response_info_; | 166 scoped_ptr<net::HttpResponseInfo> range_response_info_; |
170 scoped_ptr<AppCacheResponseReader> reader_; | 167 scoped_ptr<AppCacheResponseReader> reader_; |
171 scoped_refptr<AppCache> cache_; | 168 scoped_refptr<AppCache> cache_; |
172 scoped_refptr<AppCacheGroup> group_; | 169 scoped_refptr<AppCacheGroup> group_; |
173 base::WeakPtrFactory<AppCacheURLRequestJob> weak_factory_; | 170 base::WeakPtrFactory<AppCacheURLRequestJob> weak_factory_; |
174 }; | 171 }; |
175 | 172 |
176 } // namespace content | 173 } // namespace content |
177 | 174 |
178 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ | 175 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ |
OLD | NEW |