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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // NOTE: This is not ideal since multiple jobs may be doing this, | 194 // NOTE: This is not ideal since multiple jobs may be doing this, |
195 // concurrently but close enough for now, the first to load the script | 195 // concurrently but close enough for now, the first to load the script |
196 // will win. | 196 // will win. |
197 | 197 |
198 // Read the script data, truncating if its too large. | 198 // Read the script data, truncating if its too large. |
199 // NOTE: we just issue one read and don't bother chaining if the resource | 199 // NOTE: we just issue one read and don't bother chaining if the resource |
200 // is very (very) large, close enough for now. | 200 // is very (very) large, close enough for now. |
201 const int64_t kLimit = 500 * 1000; | 201 const int64_t kLimit = 500 * 1000; |
202 handler_source_buffer_ = new net::GrowableIOBuffer(); | 202 handler_source_buffer_ = new net::GrowableIOBuffer(); |
203 handler_source_buffer_->SetCapacity(kLimit); | 203 handler_source_buffer_->SetCapacity(kLimit); |
204 handler_source_reader_.reset(storage_->CreateResponseReader( | 204 handler_source_reader_.reset( |
205 manifest_url_, group_id_, entry_.response_id())); | 205 storage_->CreateResponseReader(manifest_url_, entry_.response_id())); |
206 handler_source_reader_->ReadData( | 206 handler_source_reader_->ReadData( |
207 handler_source_buffer_.get(), | 207 handler_source_buffer_.get(), |
208 kLimit, | 208 kLimit, |
209 base::Bind(&AppCacheURLRequestJob::OnExecutableSourceLoaded, | 209 base::Bind(&AppCacheURLRequestJob::OnExecutableSourceLoaded, |
210 base::Unretained(this))); | 210 base::Unretained(this))); |
211 } | 211 } |
212 | 212 |
213 void AppCacheURLRequestJob::OnExecutableSourceLoaded(int result) { | 213 void AppCacheURLRequestJob::OnExecutableSourceLoaded(int result) { |
214 DCHECK(!has_been_killed()); | 214 DCHECK(!has_been_killed()); |
215 handler_source_reader_.reset(); | 215 handler_source_reader_.reset(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 storage_ = NULL; | 276 storage_ = NULL; |
277 BeginDelivery(); | 277 BeginDelivery(); |
278 } | 278 } |
279 | 279 |
280 void AppCacheURLRequestJob::OnResponseInfoLoaded( | 280 void AppCacheURLRequestJob::OnResponseInfoLoaded( |
281 AppCacheResponseInfo* response_info, | 281 AppCacheResponseInfo* response_info, |
282 int64_t response_id) { | 282 int64_t response_id) { |
283 DCHECK(is_delivering_appcache_response()); | 283 DCHECK(is_delivering_appcache_response()); |
284 if (response_info) { | 284 if (response_info) { |
285 info_ = response_info; | 285 info_ = response_info; |
286 reader_.reset(storage_->CreateResponseReader( | 286 reader_.reset( |
287 manifest_url_, group_id_, entry_.response_id())); | 287 storage_->CreateResponseReader(manifest_url_, entry_.response_id())); |
288 | 288 |
289 if (is_range_request()) | 289 if (is_range_request()) |
290 SetupRangeResponse(); | 290 SetupRangeResponse(); |
291 | 291 |
292 NotifyHeadersComplete(); | 292 NotifyHeadersComplete(); |
293 } else { | 293 } else { |
294 if (storage_->service()->storage() == storage_) { | 294 if (storage_->service()->storage() == storage_) { |
295 // A resource that is expected to be in the appcache is missing. | 295 // A resource that is expected to be in the appcache is missing. |
296 // See http://code.google.com/p/chromium/issues/detail?id=50657 | 296 // See http://code.google.com/p/chromium/issues/detail?id=50657 |
297 // Instead of failing the request, we restart the request. The retry | 297 // Instead of failing the request, we restart the request. The retry |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 if (ranges.size() == 1U) | 453 if (ranges.size() == 1U) |
454 range_requested_ = ranges[0]; | 454 range_requested_ = ranges[0]; |
455 } | 455 } |
456 | 456 |
457 void AppCacheURLRequestJob::NotifyRestartRequired() { | 457 void AppCacheURLRequestJob::NotifyRestartRequired() { |
458 on_prepare_to_restart_callback_.Run(); | 458 on_prepare_to_restart_callback_.Run(); |
459 URLRequestJob::NotifyRestartRequired(); | 459 URLRequestJob::NotifyRestartRequired(); |
460 } | 460 } |
461 | 461 |
462 } // namespace content | 462 } // namespace content |
OLD | NEW |