| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_dispatcher_host.h" | 5 #include "content/browser/cache_storage/cache_storage_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 blink::WebServiceWorkerCacheErrorNotImplemented)); | 237 blink::WebServiceWorkerCacheErrorNotImplemented)); |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 IDToCacheMap::iterator it = id_to_cache_map_.find(cache_id); | 241 IDToCacheMap::iterator it = id_to_cache_map_.find(cache_id); |
| 242 if (it == id_to_cache_map_.end()) { | 242 if (it == id_to_cache_map_.end()) { |
| 243 Send(new CacheStorageMsg_CacheBatchError( | 243 Send(new CacheStorageMsg_CacheBatchError( |
| 244 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound)); | 244 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound)); |
| 245 return; | 245 return; |
| 246 } | 246 } |
| 247 | |
| 248 const CacheStorageBatchOperation& operation = operations[0]; | |
| 249 | |
| 250 scoped_refptr<CacheStorageCache> cache = it->second; | 247 scoped_refptr<CacheStorageCache> cache = it->second; |
| 251 scoped_ptr<ServiceWorkerFetchRequest> scoped_request( | 248 cache->BatchOperation( |
| 252 new ServiceWorkerFetchRequest( | 249 operations, base::Bind(&CacheStorageDispatcherHost::OnCacheBatchCallback, |
| 253 operation.request.url, operation.request.method, | |
| 254 operation.request.headers, operation.request.referrer, | |
| 255 operation.request.is_reload)); | |
| 256 | |
| 257 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE) { | |
| 258 cache->Delete(scoped_request.Pass(), | |
| 259 base::Bind(&CacheStorageDispatcherHost::OnCacheBatchCallback, | |
| 260 this, thread_id, request_id, cache)); | 250 this, thread_id, request_id, cache)); |
| 261 return; | |
| 262 } | |
| 263 | |
| 264 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT) { | |
| 265 // We don't support streaming for cache. | |
| 266 DCHECK(operation.response.stream_url.is_empty()); | |
| 267 scoped_ptr<ServiceWorkerResponse> scoped_response(new ServiceWorkerResponse( | |
| 268 operation.response.url, operation.response.status_code, | |
| 269 operation.response.status_text, operation.response.response_type, | |
| 270 operation.response.headers, operation.response.blob_uuid, | |
| 271 operation.response.blob_size, operation.response.stream_url)); | |
| 272 cache->Put(scoped_request.Pass(), scoped_response.Pass(), | |
| 273 base::Bind(&CacheStorageDispatcherHost::OnCacheBatchCallback, | |
| 274 this, thread_id, request_id, cache)); | |
| 275 | |
| 276 return; | |
| 277 } | |
| 278 | |
| 279 Send(new CacheStorageMsg_CacheBatchError( | |
| 280 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotImplemented)); | |
| 281 } | 251 } |
| 282 | 252 |
| 283 void CacheStorageDispatcherHost::OnCacheClosed(int cache_id) { | 253 void CacheStorageDispatcherHost::OnCacheClosed(int cache_id) { |
| 284 DropCacheReference(cache_id); | 254 DropCacheReference(cache_id); |
| 285 } | 255 } |
| 286 | 256 |
| 287 void CacheStorageDispatcherHost::OnBlobDataHandled(const std::string& uuid) { | 257 void CacheStorageDispatcherHost::OnBlobDataHandled(const std::string& uuid) { |
| 288 DropBlobDataHandle(uuid); | 258 DropBlobDataHandle(uuid); |
| 289 } | 259 } |
| 290 | 260 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); | 424 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); |
| 455 if (it == blob_handle_store_.end()) | 425 if (it == blob_handle_store_.end()) |
| 456 return; | 426 return; |
| 457 DCHECK(!it->second.empty()); | 427 DCHECK(!it->second.empty()); |
| 458 it->second.pop_front(); | 428 it->second.pop_front(); |
| 459 if (it->second.empty()) | 429 if (it->second.empty()) |
| 460 blob_handle_store_.erase(it); | 430 blob_handle_store_.erase(it); |
| 461 } | 431 } |
| 462 | 432 |
| 463 } // namespace content | 433 } // namespace content |
| OLD | NEW |