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 #include "content/browser/appcache/appcache_url_request_job.h" | 5 #include "content/browser/appcache/appcache_url_request_job.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 range_response_info_.reset(); | 53 range_response_info_.reset(); |
54 net::URLRequestJob::Kill(); | 54 net::URLRequestJob::Kill(); |
55 AppCacheJob::weak_factory_.InvalidateWeakPtrs(); | 55 AppCacheJob::weak_factory_.InvalidateWeakPtrs(); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 bool AppCacheURLRequestJob::IsStarted() const { | 59 bool AppCacheURLRequestJob::IsStarted() const { |
60 return has_been_started_; | 60 return has_been_started_; |
61 } | 61 } |
62 | 62 |
63 bool AppCacheURLRequestJob::IsWaiting() const { | |
64 return delivery_type_ == AWAITING_DELIVERY_ORDERS; | |
65 } | |
66 | |
67 bool AppCacheURLRequestJob::IsDeliveringAppCacheResponse() const { | |
68 return delivery_type_ == APPCACHED_DELIVERY; | |
69 } | |
70 | |
71 bool AppCacheURLRequestJob::IsDeliveringNetworkResponse() const { | |
72 return delivery_type_ == NETWORK_DELIVERY; | |
73 } | |
74 | |
75 bool AppCacheURLRequestJob::IsDeliveringErrorResponse() const { | |
76 return delivery_type_ == ERROR_DELIVERY; | |
77 } | |
78 | |
79 bool AppCacheURLRequestJob::IsCacheEntryNotFound() const { | |
80 return cache_entry_not_found_; | |
81 } | |
82 | |
83 void AppCacheURLRequestJob::DeliverAppCachedResponse(const GURL& manifest_url, | 63 void AppCacheURLRequestJob::DeliverAppCachedResponse(const GURL& manifest_url, |
84 int64_t cache_id, | 64 int64_t cache_id, |
85 const AppCacheEntry& entry, | 65 const AppCacheEntry& entry, |
86 bool is_fallback) { | 66 bool is_fallback) { |
87 DCHECK(!has_delivery_orders()); | 67 DCHECK(!has_delivery_orders()); |
88 DCHECK(entry.has_response_id()); | 68 DCHECK(entry.has_response_id()); |
89 delivery_type_ = APPCACHED_DELIVERY; | 69 delivery_type_ = APPCACHED_DELIVERY; |
90 manifest_url_ = manifest_url; | 70 manifest_url_ = manifest_url; |
91 cache_id_ = cache_id; | 71 cache_id_ = cache_id; |
92 entry_ = entry; | 72 entry_ = entry; |
(...skipping 28 matching lines...) Expand all Loading... |
121 net::NetworkDelegate* network_delegate, | 101 net::NetworkDelegate* network_delegate, |
122 AppCacheStorage* storage, | 102 AppCacheStorage* storage, |
123 AppCacheHost* host, | 103 AppCacheHost* host, |
124 bool is_main_resource, | 104 bool is_main_resource, |
125 const OnPrepareToRestartCallback& restart_callback) | 105 const OnPrepareToRestartCallback& restart_callback) |
126 : net::URLRequestJob(request, network_delegate), | 106 : net::URLRequestJob(request, network_delegate), |
127 host_(host), | 107 host_(host), |
128 storage_(storage), | 108 storage_(storage), |
129 has_been_started_(false), | 109 has_been_started_(false), |
130 has_been_killed_(false), | 110 has_been_killed_(false), |
131 delivery_type_(AWAITING_DELIVERY_ORDERS), | |
132 cache_id_(kAppCacheNoCacheId), | 111 cache_id_(kAppCacheNoCacheId), |
133 is_fallback_(false), | 112 is_fallback_(false), |
134 is_main_resource_(is_main_resource), | 113 is_main_resource_(is_main_resource), |
135 cache_entry_not_found_(false), | |
136 on_prepare_to_restart_callback_(restart_callback) { | 114 on_prepare_to_restart_callback_(restart_callback) { |
137 DCHECK(storage_); | 115 DCHECK(storage_); |
138 } | 116 } |
139 | 117 |
140 void AppCacheURLRequestJob::MaybeBeginDelivery() { | 118 void AppCacheURLRequestJob::MaybeBeginDelivery() { |
141 if (IsStarted() && has_delivery_orders()) { | 119 if (IsStarted() && has_delivery_orders()) { |
142 // Start asynchronously so that all error reporting and data | 120 // Start asynchronously so that all error reporting and data |
143 // callbacks happen as they would for network requests. | 121 // callbacks happen as they would for network requests. |
144 base::ThreadTaskRunnerHandle::Get()->PostTask( | 122 base::ThreadTaskRunnerHandle::Get()->PostTask( |
145 FROM_HERE, base::Bind(&AppCacheURLRequestJob::BeginDelivery, | 123 FROM_HERE, base::Bind(&AppCacheURLRequestJob::BeginDelivery, |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if (ranges.size() == 1U) | 452 if (ranges.size() == 1U) |
475 range_requested_ = ranges[0]; | 453 range_requested_ = ranges[0]; |
476 } | 454 } |
477 | 455 |
478 void AppCacheURLRequestJob::NotifyRestartRequired() { | 456 void AppCacheURLRequestJob::NotifyRestartRequired() { |
479 on_prepare_to_restart_callback_.Run(); | 457 on_prepare_to_restart_callback_.Run(); |
480 URLRequestJob::NotifyRestartRequired(); | 458 URLRequestJob::NotifyRestartRequired(); |
481 } | 459 } |
482 | 460 |
483 } // namespace content | 461 } // namespace content |
OLD | NEW |