| 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/cache_storage/cache_storage_cache.h" | 5 #include "content/browser/cache_storage/cache_storage_cache.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/barrier_closure.h" | 9 #include "base/barrier_closure.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 } | 757 } |
| 758 | 758 |
| 759 void CacheStorageCache::Put(const CacheStorageBatchOperation& operation, | 759 void CacheStorageCache::Put(const CacheStorageBatchOperation& operation, |
| 760 const ErrorCallback& callback) { | 760 const ErrorCallback& callback) { |
| 761 DCHECK(BACKEND_OPEN == backend_state_ || initializing_); | 761 DCHECK(BACKEND_OPEN == backend_state_ || initializing_); |
| 762 DCHECK_EQ(CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT, operation.operation_type); | 762 DCHECK_EQ(CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT, operation.operation_type); |
| 763 | 763 |
| 764 scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest( | 764 scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest( |
| 765 operation.request.url, operation.request.method, | 765 operation.request.url, operation.request.method, |
| 766 operation.request.headers, operation.request.referrer, | 766 operation.request.headers, operation.request.referrer, |
| 767 operation.request.is_reload)); | 767 operation.request.is_reload, operation.request.client)); |
| 768 | 768 |
| 769 // We don't support streaming for cache. | 769 // We don't support streaming for cache. |
| 770 DCHECK(operation.response.stream_url.is_empty()); | 770 DCHECK(operation.response.stream_url.is_empty()); |
| 771 scoped_ptr<ServiceWorkerResponse> response(new ServiceWorkerResponse( | 771 scoped_ptr<ServiceWorkerResponse> response(new ServiceWorkerResponse( |
| 772 operation.response.url, operation.response.status_code, | 772 operation.response.url, operation.response.status_code, |
| 773 operation.response.status_text, operation.response.response_type, | 773 operation.response.status_text, operation.response.response_type, |
| 774 operation.response.headers, operation.response.blob_uuid, | 774 operation.response.headers, operation.response.blob_uuid, |
| 775 operation.response.blob_size, operation.response.stream_url)); | 775 operation.response.blob_size, operation.response.stream_url)); |
| 776 | 776 |
| 777 scoped_ptr<storage::BlobDataHandle> blob_data_handle; | 777 scoped_ptr<storage::BlobDataHandle> blob_data_handle; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 | 972 |
| 973 void CacheStorageCache::Delete(const CacheStorageBatchOperation& operation, | 973 void CacheStorageCache::Delete(const CacheStorageBatchOperation& operation, |
| 974 const ErrorCallback& callback) { | 974 const ErrorCallback& callback) { |
| 975 DCHECK(BACKEND_OPEN == backend_state_ || initializing_); | 975 DCHECK(BACKEND_OPEN == backend_state_ || initializing_); |
| 976 DCHECK_EQ(CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE, | 976 DCHECK_EQ(CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE, |
| 977 operation.operation_type); | 977 operation.operation_type); |
| 978 | 978 |
| 979 scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest( | 979 scoped_ptr<ServiceWorkerFetchRequest> request(new ServiceWorkerFetchRequest( |
| 980 operation.request.url, operation.request.method, | 980 operation.request.url, operation.request.method, |
| 981 operation.request.headers, operation.request.referrer, | 981 operation.request.headers, operation.request.referrer, |
| 982 operation.request.is_reload)); | 982 operation.request.is_reload, operation.request.client)); |
| 983 | 983 |
| 984 ErrorCallback pending_callback = | 984 ErrorCallback pending_callback = |
| 985 base::Bind(&CacheStorageCache::PendingErrorCallback, | 985 base::Bind(&CacheStorageCache::PendingErrorCallback, |
| 986 weak_ptr_factory_.GetWeakPtr(), callback); | 986 weak_ptr_factory_.GetWeakPtr(), callback); |
| 987 scheduler_->ScheduleOperation( | 987 scheduler_->ScheduleOperation( |
| 988 base::Bind(&CacheStorageCache::DeleteImpl, weak_ptr_factory_.GetWeakPtr(), | 988 base::Bind(&CacheStorageCache::DeleteImpl, weak_ptr_factory_.GetWeakPtr(), |
| 989 base::Passed(request.Pass()), pending_callback)); | 989 base::Passed(request.Pass()), pending_callback)); |
| 990 } | 990 } |
| 991 | 991 |
| 992 void CacheStorageCache::DeleteImpl( | 992 void CacheStorageCache::DeleteImpl( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 | 1131 |
| 1132 void CacheStorageCache::KeysDidReadMetadata( | 1132 void CacheStorageCache::KeysDidReadMetadata( |
| 1133 scoped_ptr<KeysContext> keys_context, | 1133 scoped_ptr<KeysContext> keys_context, |
| 1134 const Entries::iterator& iter, | 1134 const Entries::iterator& iter, |
| 1135 scoped_ptr<CacheMetadata> metadata) { | 1135 scoped_ptr<CacheMetadata> metadata) { |
| 1136 disk_cache::Entry* entry = *iter; | 1136 disk_cache::Entry* entry = *iter; |
| 1137 | 1137 |
| 1138 if (metadata) { | 1138 if (metadata) { |
| 1139 keys_context->out_keys->push_back(ServiceWorkerFetchRequest( | 1139 keys_context->out_keys->push_back(ServiceWorkerFetchRequest( |
| 1140 GURL(entry->GetKey()), metadata->request().method(), | 1140 GURL(entry->GetKey()), metadata->request().method(), |
| 1141 ServiceWorkerHeaderMap(), Referrer(), false)); | 1141 ServiceWorkerHeaderMap(), Referrer(), false, |
| 1142 ServiceWorkerClientInfo())); |
| 1142 | 1143 |
| 1143 ServiceWorkerHeaderMap& req_headers = | 1144 ServiceWorkerHeaderMap& req_headers = |
| 1144 keys_context->out_keys->back().headers; | 1145 keys_context->out_keys->back().headers; |
| 1145 | 1146 |
| 1146 for (int i = 0; i < metadata->request().headers_size(); ++i) { | 1147 for (int i = 0; i < metadata->request().headers_size(); ++i) { |
| 1147 const CacheHeaderMap header = metadata->request().headers(i); | 1148 const CacheHeaderMap header = metadata->request().headers(i); |
| 1148 DCHECK(header.name().find('\0') == std::string::npos); | 1149 DCHECK(header.name().find('\0') == std::string::npos); |
| 1149 DCHECK(header.value().find('\0') == std::string::npos); | 1150 DCHECK(header.value().find('\0') == std::string::npos); |
| 1150 req_headers.insert(std::make_pair(header.name(), header.value())); | 1151 req_headers.insert(std::make_pair(header.name(), header.value())); |
| 1151 } | 1152 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 CacheStorageError error, | 1267 CacheStorageError error, |
| 1267 scoped_ptr<Requests> requests) { | 1268 scoped_ptr<Requests> requests) { |
| 1268 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); | 1269 base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); |
| 1269 | 1270 |
| 1270 callback.Run(error, requests.Pass()); | 1271 callback.Run(error, requests.Pass()); |
| 1271 if (cache) | 1272 if (cache) |
| 1272 scheduler_->CompleteOperationAndRunNext(); | 1273 scheduler_->CompleteOperationAndRunNext(); |
| 1273 } | 1274 } |
| 1274 | 1275 |
| 1275 } // namespace content | 1276 } // namespace content |
| OLD | NEW |