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_cache.h" | 5 #include "content/browser/service_worker/service_worker_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 scoped_ptr<storage::BlobDataHandle>()); | 487 scoped_ptr<storage::BlobDataHandle>()); |
488 return; | 488 return; |
489 } | 489 } |
490 | 490 |
491 scoped_ptr<ServiceWorkerResponse> response(new ServiceWorkerResponse( | 491 scoped_ptr<ServiceWorkerResponse> response(new ServiceWorkerResponse( |
492 request->url, | 492 request->url, |
493 headers->status_code(), | 493 headers->status_code(), |
494 headers->status_text(), | 494 headers->status_text(), |
495 ProtoResponseTypeToWebResponseType(headers->response_type()), | 495 ProtoResponseTypeToWebResponseType(headers->response_type()), |
496 ServiceWorkerHeaderMap(), | 496 ServiceWorkerHeaderMap(), |
497 "")); | 497 "", |
| 498 0)); |
498 | 499 |
499 for (int i = 0; i < headers->response_headers_size(); ++i) { | 500 for (int i = 0; i < headers->response_headers_size(); ++i) { |
500 const ServiceWorkerRequestResponseHeaders::HeaderMap header = | 501 const ServiceWorkerRequestResponseHeaders::HeaderMap header = |
501 headers->response_headers(i); | 502 headers->response_headers(i); |
502 response->headers.insert(std::make_pair(header.name(), header.value())); | 503 response->headers.insert(std::make_pair(header.name(), header.value())); |
503 } | 504 } |
504 | 505 |
505 ServiceWorkerHeaderMap cached_request_headers; | 506 ServiceWorkerHeaderMap cached_request_headers; |
506 for (int i = 0; i < headers->request_headers_size(); ++i) { | 507 for (int i = 0; i < headers->request_headers_size(); ++i) { |
507 const ServiceWorkerRequestResponseHeaders::HeaderMap header = | 508 const ServiceWorkerRequestResponseHeaders::HeaderMap header = |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 scoped_ptr<ResponseReadContext> response_context, | 574 scoped_ptr<ResponseReadContext> response_context, |
574 int rv) { | 575 int rv) { |
575 if (rv < 0) { | 576 if (rv < 0) { |
576 callback.Run(ServiceWorkerCache::ErrorTypeStorage, | 577 callback.Run(ServiceWorkerCache::ErrorTypeStorage, |
577 scoped_ptr<ServiceWorkerResponse>(), | 578 scoped_ptr<ServiceWorkerResponse>(), |
578 scoped_ptr<storage::BlobDataHandle>()); | 579 scoped_ptr<storage::BlobDataHandle>()); |
579 return; | 580 return; |
580 } | 581 } |
581 | 582 |
582 if (rv == 0) { | 583 if (rv == 0) { |
| 584 response->blob_uuid = response_context->blob_data->uuid(); |
| 585 response->blob_size = response_context->total_bytes_read; |
583 MatchDoneWithBody(request.Pass(), | 586 MatchDoneWithBody(request.Pass(), |
584 callback, | 587 callback, |
585 blob_storage, | 588 blob_storage, |
586 response.Pass(), | 589 response.Pass(), |
587 response_context.Pass()); | 590 response_context.Pass()); |
588 return; | 591 return; |
589 } | 592 } |
590 | 593 |
591 // TODO(jkarlin): This copying of the the entire cache response into memory is | 594 // TODO(jkarlin): This copying of the the entire cache response into memory is |
592 // awful. Create a new interface around SimpleCache that provides access the | 595 // awful. Create a new interface around SimpleCache that provides access the |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 initialized_ = true; | 1099 initialized_ = true; |
1097 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); | 1100 for (std::vector<base::Closure>::iterator it = init_callbacks_.begin(); |
1098 it != init_callbacks_.end(); | 1101 it != init_callbacks_.end(); |
1099 ++it) { | 1102 ++it) { |
1100 it->Run(); | 1103 it->Run(); |
1101 } | 1104 } |
1102 init_callbacks_.clear(); | 1105 init_callbacks_.clear(); |
1103 } | 1106 } |
1104 | 1107 |
1105 } // namespace content | 1108 } // namespace content |
OLD | NEW |