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 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "webkit/appcache/appcache_url_request_job.h" | 7 #include "webkit/appcache/appcache_url_request_job.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 net::URLRequest* request, AppCacheStorage* storage) | 27 net::URLRequest* request, AppCacheStorage* storage) |
28 : net::URLRequestJob(request), storage_(storage), | 28 : net::URLRequestJob(request), storage_(storage), |
29 has_been_started_(false), has_been_killed_(false), | 29 has_been_started_(false), has_been_killed_(false), |
30 delivery_type_(AWAITING_DELIVERY_ORDERS), | 30 delivery_type_(AWAITING_DELIVERY_ORDERS), |
31 group_id_(0), cache_id_(kNoCacheId), is_fallback_(false), | 31 group_id_(0), cache_id_(kNoCacheId), is_fallback_(false), |
32 cache_entry_not_found_(false), | 32 cache_entry_not_found_(false), |
33 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 33 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
34 DCHECK(storage_); | 34 DCHECK(storage_); |
35 } | 35 } |
36 | 36 |
37 AppCacheURLRequestJob::~AppCacheURLRequestJob() { | |
38 if (storage_) | |
39 storage_->CancelDelegateCallbacks(this); | |
40 } | |
41 | |
42 void AppCacheURLRequestJob::DeliverAppCachedResponse( | 37 void AppCacheURLRequestJob::DeliverAppCachedResponse( |
43 const GURL& manifest_url, int64 group_id, int64 cache_id, | 38 const GURL& manifest_url, int64 group_id, int64 cache_id, |
44 const AppCacheEntry& entry, bool is_fallback) { | 39 const AppCacheEntry& entry, bool is_fallback) { |
45 DCHECK(!has_delivery_orders()); | 40 DCHECK(!has_delivery_orders()); |
46 DCHECK(entry.has_response_id()); | 41 DCHECK(entry.has_response_id()); |
47 delivery_type_ = APPCACHED_DELIVERY; | 42 delivery_type_ = APPCACHED_DELIVERY; |
48 manifest_url_ = manifest_url; | 43 manifest_url_ = manifest_url; |
49 group_id_ = group_id; | 44 group_id_ = group_id; |
50 cache_id_ = cache_id; | 45 cache_id_ = cache_id; |
51 entry_ = entry; | 46 entry_ = entry; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 storage_->LoadResponseInfo( | 104 storage_->LoadResponseInfo( |
110 manifest_url_, group_id_, entry_.response_id(), this); | 105 manifest_url_, group_id_, entry_.response_id(), this); |
111 break; | 106 break; |
112 | 107 |
113 default: | 108 default: |
114 NOTREACHED(); | 109 NOTREACHED(); |
115 break; | 110 break; |
116 } | 111 } |
117 } | 112 } |
118 | 113 |
| 114 AppCacheURLRequestJob::~AppCacheURLRequestJob() { |
| 115 if (storage_) |
| 116 storage_->CancelDelegateCallbacks(this); |
| 117 } |
| 118 |
119 void AppCacheURLRequestJob::OnResponseInfoLoaded( | 119 void AppCacheURLRequestJob::OnResponseInfoLoaded( |
120 AppCacheResponseInfo* response_info, int64 response_id) { | 120 AppCacheResponseInfo* response_info, int64 response_id) { |
121 DCHECK(is_delivering_appcache_response()); | 121 DCHECK(is_delivering_appcache_response()); |
122 scoped_refptr<AppCacheURLRequestJob> protect(this); | 122 scoped_refptr<AppCacheURLRequestJob> protect(this); |
123 if (response_info) { | 123 if (response_info) { |
124 info_ = response_info; | 124 info_ = response_info; |
125 reader_.reset(storage_->CreateResponseReader( | 125 reader_.reset(storage_->CreateResponseReader( |
126 manifest_url_, group_id_, entry_.response_id())); | 126 manifest_url_, group_id_, entry_.response_id())); |
127 | 127 |
128 if (is_range_request()) | 128 if (is_range_request()) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 return; | 284 return; |
285 } | 285 } |
286 | 286 |
287 // If multiple ranges are requested, we play dumb and | 287 // If multiple ranges are requested, we play dumb and |
288 // return the entire response with 200 OK. | 288 // return the entire response with 200 OK. |
289 if (ranges.size() == 1U) | 289 if (ranges.size() == 1U) |
290 range_requested_ = ranges[0]; | 290 range_requested_ = ranges[0]; |
291 } | 291 } |
292 | 292 |
293 } // namespace appcache | 293 } // namespace appcache |
OLD | NEW |