| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/service_worker/service_worker_read_from_cache_job.h" | 5 #include "content/browser/service_worker/service_worker_read_from_cache_job.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 NotifyStartError(net::URLRequestStatus( | 40 NotifyStartError(net::URLRequestStatus( |
| 41 net::URLRequestStatus::FAILED, net::ERR_FAILED)); | 41 net::URLRequestStatus::FAILED, net::ERR_FAILED)); |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Create a response reader and start reading the headers, | 45 // Create a response reader and start reading the headers, |
| 46 // we'll continue when thats done. | 46 // we'll continue when thats done. |
| 47 reader_ = context_->storage()->CreateResponseReader(response_id_); | 47 reader_ = context_->storage()->CreateResponseReader(response_id_); |
| 48 http_info_io_buffer_ = new HttpResponseInfoIOBuffer; | 48 http_info_io_buffer_ = new HttpResponseInfoIOBuffer; |
| 49 reader_->ReadInfo( | 49 reader_->ReadInfo( |
| 50 http_info_io_buffer_, | 50 http_info_io_buffer_.get(), |
| 51 base::Bind(&ServiceWorkerReadFromCacheJob::OnReadInfoComplete, | 51 base::Bind(&ServiceWorkerReadFromCacheJob::OnReadInfoComplete, |
| 52 weak_factory_.GetWeakPtr())); | 52 weak_factory_.GetWeakPtr())); |
| 53 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); | 53 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ServiceWorkerReadFromCacheJob::Kill() { | 56 void ServiceWorkerReadFromCacheJob::Kill() { |
| 57 if (has_been_killed_) | 57 if (has_been_killed_) |
| 58 return; | 58 return; |
| 59 weak_factory_.InvalidateWeakPtrs(); | 59 weak_factory_.InvalidateWeakPtrs(); |
| 60 has_been_killed_ = true; | 60 has_been_killed_ = true; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result)); | 185 NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result)); |
| 186 } else { | 186 } else { |
| 187 check_result = ServiceWorkerMetrics::READ_OK; | 187 check_result = ServiceWorkerMetrics::READ_OK; |
| 188 SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status | 188 SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status |
| 189 } | 189 } |
| 190 ServiceWorkerMetrics::CountReadResponseResult(check_result); | 190 ServiceWorkerMetrics::CountReadResponseResult(check_result); |
| 191 NotifyReadComplete(result); | 191 NotifyReadComplete(result); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace content | 194 } // namespace content |
| OLD | NEW |