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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 blink::WebServiceWorkerCacheErrorNotImplemented)); | 264 blink::WebServiceWorkerCacheErrorNotImplemented)); |
265 return; | 265 return; |
266 } | 266 } |
267 | 267 |
268 IDToCacheMap::iterator it = id_to_cache_map_.find(cache_id); | 268 IDToCacheMap::iterator it = id_to_cache_map_.find(cache_id); |
269 if (it == id_to_cache_map_.end()) { | 269 if (it == id_to_cache_map_.end()) { |
270 Send(new CacheStorageMsg_CacheBatchError( | 270 Send(new CacheStorageMsg_CacheBatchError( |
271 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound)); | 271 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound)); |
272 return; | 272 return; |
273 } | 273 } |
274 | |
275 const CacheStorageBatchOperation& operation = operations[0]; | |
276 | |
277 scoped_refptr<CacheStorageCache> cache = it->second; | 274 scoped_refptr<CacheStorageCache> cache = it->second; |
278 scoped_ptr<ServiceWorkerFetchRequest> scoped_request( | 275 cache->BatchOperation( |
279 new ServiceWorkerFetchRequest( | 276 operations, base::Bind(&CacheStorageDispatcherHost::OnCacheBatchCallback, |
280 operation.request.url, operation.request.method, | |
281 operation.request.headers, operation.request.referrer, | |
282 operation.request.is_reload)); | |
283 | |
284 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE) { | |
285 cache->Delete(scoped_request.Pass(), | |
286 base::Bind(&CacheStorageDispatcherHost::OnCacheBatchCallback, | |
287 this, thread_id, request_id, cache)); | 277 this, thread_id, request_id, cache)); |
288 return; | |
289 } | |
290 | |
291 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT) { | |
292 // We don't support streaming for cache. | |
293 DCHECK(operation.response.stream_url.is_empty()); | |
294 scoped_ptr<ServiceWorkerResponse> scoped_response(new ServiceWorkerResponse( | |
295 operation.response.url, operation.response.status_code, | |
296 operation.response.status_text, operation.response.response_type, | |
297 operation.response.headers, operation.response.blob_uuid, | |
298 operation.response.blob_size, operation.response.stream_url)); | |
299 cache->Put(scoped_request.Pass(), scoped_response.Pass(), | |
300 base::Bind(&CacheStorageDispatcherHost::OnCacheBatchCallback, | |
301 this, thread_id, request_id, cache)); | |
302 | |
303 return; | |
304 } | |
305 | |
306 Send(new CacheStorageMsg_CacheBatchError( | |
307 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotImplemented)); | |
308 } | 278 } |
309 | 279 |
310 void CacheStorageDispatcherHost::OnCacheClosed(int cache_id) { | 280 void CacheStorageDispatcherHost::OnCacheClosed(int cache_id) { |
311 DropCacheReference(cache_id); | 281 DropCacheReference(cache_id); |
312 } | 282 } |
313 | 283 |
314 void CacheStorageDispatcherHost::OnBlobDataHandled(const std::string& uuid) { | 284 void CacheStorageDispatcherHost::OnBlobDataHandled(const std::string& uuid) { |
315 DropBlobDataHandle(uuid); | 285 DropBlobDataHandle(uuid); |
316 } | 286 } |
317 | 287 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); | 451 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); |
482 if (it == blob_handle_store_.end()) | 452 if (it == blob_handle_store_.end()) |
483 return; | 453 return; |
484 DCHECK(!it->second.empty()); | 454 DCHECK(!it->second.empty()); |
485 it->second.pop_front(); | 455 it->second.pop_front(); |
486 if (it->second.empty()) | 456 if (it->second.empty()) |
487 blob_handle_store_.erase(it); | 457 blob_handle_store_.erase(it); |
488 } | 458 } |
489 | 459 |
490 } // namespace content | 460 } // namespace content |
OLD | NEW |