Chromium Code Reviews| 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/renderer/cache_storage/cache_storage_dispatcher.h" | 5 #include "content/renderer/cache_storage/cache_storage_dispatcher.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 operation.response = ResponseFromWebResponse(web_operation.response); | 121 operation.response = ResponseFromWebResponse(web_operation.response); |
| 122 operation.match_params = | 122 operation.match_params = |
| 123 QueryParamsFromWebQueryParams(web_operation.matchParams); | 123 QueryParamsFromWebQueryParams(web_operation.matchParams); |
| 124 return operation; | 124 return operation; |
| 125 } | 125 } |
| 126 | 126 |
| 127 template <typename T> | 127 template <typename T> |
| 128 void ClearCallbacksMapWithErrors(T* callbacks_map) { | 128 void ClearCallbacksMapWithErrors(T* callbacks_map) { |
| 129 typename T::iterator iter(callbacks_map); | 129 typename T::iterator iter(callbacks_map); |
| 130 while (!iter.IsAtEnd()) { | 130 while (!iter.IsAtEnd()) { |
| 131 iter.GetCurrentValue()->onError( | |
| 132 new blink::WebServiceWorkerCacheError( | |
| 133 blink::WebServiceWorkerCacheErrorNotFound)); | |
| 134 callbacks_map->Remove(iter.GetCurrentKey()); | |
| 135 iter.Advance(); | |
| 136 } | |
| 137 } | |
| 138 | |
| 139 template <typename T> | |
| 140 void ClearCallbacksMapWithErrorsNonPtr(T* callbacks_map) { | |
| 141 typename T::iterator iter(callbacks_map); | |
| 142 while (!iter.IsAtEnd()) { | |
| 143 iter.GetCurrentValue()->onError(blink::WebServiceWorkerCacheError( | 131 iter.GetCurrentValue()->onError(blink::WebServiceWorkerCacheError( |
| 144 blink::WebServiceWorkerCacheErrorNotFound)); | 132 blink::WebServiceWorkerCacheErrorNotFound)); |
|
nhiroki
2015/08/19 11:29:42
onError(blink::WebServiceWorkerCacheErrorNotFound)
yhirano
2015/08/19 11:39:41
Done.
| |
| 145 callbacks_map->Remove(iter.GetCurrentKey()); | 133 callbacks_map->Remove(iter.GetCurrentKey()); |
| 146 iter.Advance(); | 134 iter.Advance(); |
| 147 } | 135 } |
| 148 } | 136 } |
| 149 | 137 |
| 150 } // namespace | 138 } // namespace |
| 151 | 139 |
| 152 // The WebCache object is the Chromium side implementation of the Blink | 140 // The WebCache object is the Chromium side implementation of the Blink |
| 153 // WebServiceWorkerCache API. Most of its methods delegate directly to the | 141 // WebServiceWorkerCache API. Most of its methods delegate directly to the |
| 154 // ServiceWorkerStorage object, which is able to assign unique IDs as well | 142 // ServiceWorkerStorage object, which is able to assign unique IDs as well |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 CacheStorageDispatcher::~CacheStorageDispatcher() { | 198 CacheStorageDispatcher::~CacheStorageDispatcher() { |
| 211 ClearCallbacksMapWithErrors(&has_callbacks_); | 199 ClearCallbacksMapWithErrors(&has_callbacks_); |
| 212 ClearCallbacksMapWithErrors(&open_callbacks_); | 200 ClearCallbacksMapWithErrors(&open_callbacks_); |
| 213 ClearCallbacksMapWithErrors(&delete_callbacks_); | 201 ClearCallbacksMapWithErrors(&delete_callbacks_); |
| 214 ClearCallbacksMapWithErrors(&keys_callbacks_); | 202 ClearCallbacksMapWithErrors(&keys_callbacks_); |
| 215 ClearCallbacksMapWithErrors(&match_callbacks_); | 203 ClearCallbacksMapWithErrors(&match_callbacks_); |
| 216 | 204 |
| 217 ClearCallbacksMapWithErrors(&cache_match_callbacks_); | 205 ClearCallbacksMapWithErrors(&cache_match_callbacks_); |
| 218 ClearCallbacksMapWithErrors(&cache_match_all_callbacks_); | 206 ClearCallbacksMapWithErrors(&cache_match_all_callbacks_); |
| 219 ClearCallbacksMapWithErrors(&cache_keys_callbacks_); | 207 ClearCallbacksMapWithErrors(&cache_keys_callbacks_); |
| 220 ClearCallbacksMapWithErrorsNonPtr(&cache_batch_callbacks_); | 208 ClearCallbacksMapWithErrors(&cache_batch_callbacks_); |
| 221 | 209 |
| 222 g_cache_storage_dispatcher_tls.Pointer()->Set(kHasBeenDeleted); | 210 g_cache_storage_dispatcher_tls.Pointer()->Set(kHasBeenDeleted); |
| 223 } | 211 } |
| 224 | 212 |
| 225 CacheStorageDispatcher* CacheStorageDispatcher::ThreadSpecificInstance( | 213 CacheStorageDispatcher* CacheStorageDispatcher::ThreadSpecificInstance( |
| 226 ThreadSafeSender* thread_safe_sender) { | 214 ThreadSafeSender* thread_safe_sender) { |
| 227 if (g_cache_storage_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { | 215 if (g_cache_storage_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { |
| 228 NOTREACHED() << "Re-instantiating TLS CacheStorageDispatcher."; | 216 NOTREACHED() << "Re-instantiating TLS CacheStorageDispatcher."; |
| 229 g_cache_storage_dispatcher_tls.Pointer()->Set(NULL); | 217 g_cache_storage_dispatcher_tls.Pointer()->Set(NULL); |
| 230 } | 218 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 has_callbacks_.Lookup(request_id); | 284 has_callbacks_.Lookup(request_id); |
| 297 callbacks->onSuccess(); | 285 callbacks->onSuccess(); |
| 298 has_callbacks_.Remove(request_id); | 286 has_callbacks_.Remove(request_id); |
| 299 has_times_.erase(request_id); | 287 has_times_.erase(request_id); |
| 300 } | 288 } |
| 301 | 289 |
| 302 void CacheStorageDispatcher::OnCacheStorageOpenSuccess(int thread_id, | 290 void CacheStorageDispatcher::OnCacheStorageOpenSuccess(int thread_id, |
| 303 int request_id, | 291 int request_id, |
| 304 int cache_id) { | 292 int cache_id) { |
| 305 DCHECK_EQ(thread_id, CurrentWorkerId()); | 293 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 306 WebCache* web_cache = new WebCache(weak_factory_.GetWeakPtr(), cache_id); | 294 scoped_ptr<WebCache> web_cache( |
| 307 web_caches_.AddWithID(web_cache, cache_id); | 295 new WebCache(weak_factory_.GetWeakPtr(), cache_id)); |
| 296 web_caches_.AddWithID(web_cache.get(), cache_id); | |
| 308 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Open", | 297 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Open", |
| 309 TimeTicks::Now() - open_times_[request_id]); | 298 TimeTicks::Now() - open_times_[request_id]); |
| 310 WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks* callbacks = | 299 WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks* callbacks = |
| 311 open_callbacks_.Lookup(request_id); | 300 open_callbacks_.Lookup(request_id); |
| 312 callbacks->onSuccess(web_cache); | 301 callbacks->onSuccess(blink::adoptWebPtr(web_cache.release())); |
| 313 open_callbacks_.Remove(request_id); | 302 open_callbacks_.Remove(request_id); |
| 314 open_times_.erase(request_id); | 303 open_times_.erase(request_id); |
| 315 } | 304 } |
| 316 | 305 |
| 317 void CacheStorageDispatcher::OnCacheStorageDeleteSuccess(int thread_id, | 306 void CacheStorageDispatcher::OnCacheStorageDeleteSuccess(int thread_id, |
| 318 int request_id) { | 307 int request_id) { |
| 319 DCHECK_EQ(thread_id, CurrentWorkerId()); | 308 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 320 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Delete", | 309 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Delete", |
| 321 TimeTicks::Now() - delete_times_[request_id]); | 310 TimeTicks::Now() - delete_times_[request_id]); |
| 322 WebServiceWorkerCacheStorage::CacheStorageCallbacks* callbacks = | 311 WebServiceWorkerCacheStorage::CacheStorageCallbacks* callbacks = |
| 323 delete_callbacks_.Lookup(request_id); | 312 delete_callbacks_.Lookup(request_id); |
| 324 callbacks->onSuccess(); | 313 callbacks->onSuccess(); |
| 325 delete_callbacks_.Remove(request_id); | 314 delete_callbacks_.Remove(request_id); |
| 326 delete_times_.erase(request_id); | 315 delete_times_.erase(request_id); |
| 327 } | 316 } |
| 328 | 317 |
| 329 void CacheStorageDispatcher::OnCacheStorageKeysSuccess( | 318 void CacheStorageDispatcher::OnCacheStorageKeysSuccess( |
| 330 int thread_id, | 319 int thread_id, |
| 331 int request_id, | 320 int request_id, |
| 332 const std::vector<base::string16>& keys) { | 321 const std::vector<base::string16>& keys) { |
| 333 DCHECK_EQ(thread_id, CurrentWorkerId()); | 322 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 334 blink::WebVector<blink::WebString> webKeys(keys.size()); | 323 blink::WebVector<blink::WebString> webKeys(keys.size()); |
| 335 for (size_t i = 0; i < keys.size(); ++i) | 324 for (size_t i = 0; i < keys.size(); ++i) |
| 336 webKeys[i] = keys[i]; | 325 webKeys[i] = keys[i]; |
| 337 | 326 |
| 338 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Keys", | 327 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Keys", |
| 339 TimeTicks::Now() - keys_times_[request_id]); | 328 TimeTicks::Now() - keys_times_[request_id]); |
| 340 WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks* callbacks = | 329 WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks* callbacks = |
| 341 keys_callbacks_.Lookup(request_id); | 330 keys_callbacks_.Lookup(request_id); |
| 342 callbacks->onSuccess(&webKeys); | 331 callbacks->onSuccess(webKeys); |
| 343 keys_callbacks_.Remove(request_id); | 332 keys_callbacks_.Remove(request_id); |
| 344 keys_times_.erase(request_id); | 333 keys_times_.erase(request_id); |
| 345 } | 334 } |
| 346 | 335 |
| 347 void CacheStorageDispatcher::OnCacheStorageMatchSuccess( | 336 void CacheStorageDispatcher::OnCacheStorageMatchSuccess( |
| 348 int thread_id, | 337 int thread_id, |
| 349 int request_id, | 338 int request_id, |
| 350 const ServiceWorkerResponse& response) { | 339 const ServiceWorkerResponse& response) { |
| 351 DCHECK_EQ(thread_id, CurrentWorkerId()); | 340 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 352 blink::WebServiceWorkerResponse web_response; | 341 blink::WebServiceWorkerResponse web_response; |
| 353 PopulateWebResponseFromResponse(response, &web_response); | 342 PopulateWebResponseFromResponse(response, &web_response); |
| 354 | 343 |
| 355 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Match", | 344 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Match", |
| 356 TimeTicks::Now() - match_times_[request_id]); | 345 TimeTicks::Now() - match_times_[request_id]); |
| 357 WebServiceWorkerCacheStorage::CacheStorageMatchCallbacks* callbacks = | 346 WebServiceWorkerCacheStorage::CacheStorageMatchCallbacks* callbacks = |
| 358 match_callbacks_.Lookup(request_id); | 347 match_callbacks_.Lookup(request_id); |
| 359 callbacks->onSuccess(&web_response); | 348 callbacks->onSuccess(web_response); |
| 360 match_callbacks_.Remove(request_id); | 349 match_callbacks_.Remove(request_id); |
| 361 match_times_.erase(request_id); | 350 match_times_.erase(request_id); |
| 362 } | 351 } |
| 363 | 352 |
| 364 void CacheStorageDispatcher::OnCacheStorageHasError( | 353 void CacheStorageDispatcher::OnCacheStorageHasError( |
| 365 int thread_id, | 354 int thread_id, |
| 366 int request_id, | 355 int request_id, |
| 367 blink::WebServiceWorkerCacheError reason) { | 356 blink::WebServiceWorkerCacheError reason) { |
| 368 DCHECK_EQ(thread_id, CurrentWorkerId()); | 357 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 369 WebServiceWorkerCacheStorage::CacheStorageCallbacks* callbacks = | 358 WebServiceWorkerCacheStorage::CacheStorageCallbacks* callbacks = |
| 370 has_callbacks_.Lookup(request_id); | 359 has_callbacks_.Lookup(request_id); |
| 371 callbacks->onError(new blink::WebServiceWorkerCacheError(reason)); | 360 callbacks->onError(reason); |
| 372 has_callbacks_.Remove(request_id); | 361 has_callbacks_.Remove(request_id); |
| 373 has_times_.erase(request_id); | 362 has_times_.erase(request_id); |
| 374 } | 363 } |
| 375 | 364 |
| 376 void CacheStorageDispatcher::OnCacheStorageOpenError( | 365 void CacheStorageDispatcher::OnCacheStorageOpenError( |
| 377 int thread_id, | 366 int thread_id, |
| 378 int request_id, | 367 int request_id, |
| 379 blink::WebServiceWorkerCacheError reason) { | 368 blink::WebServiceWorkerCacheError reason) { |
| 380 DCHECK_EQ(thread_id, CurrentWorkerId()); | 369 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 381 WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks* callbacks = | 370 WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks* callbacks = |
| 382 open_callbacks_.Lookup(request_id); | 371 open_callbacks_.Lookup(request_id); |
| 383 callbacks->onError(new blink::WebServiceWorkerCacheError(reason)); | 372 callbacks->onError(reason); |
| 384 open_callbacks_.Remove(request_id); | 373 open_callbacks_.Remove(request_id); |
| 385 open_times_.erase(request_id); | 374 open_times_.erase(request_id); |
| 386 } | 375 } |
| 387 | 376 |
| 388 void CacheStorageDispatcher::OnCacheStorageDeleteError( | 377 void CacheStorageDispatcher::OnCacheStorageDeleteError( |
| 389 int thread_id, | 378 int thread_id, |
| 390 int request_id, | 379 int request_id, |
| 391 blink::WebServiceWorkerCacheError reason) { | 380 blink::WebServiceWorkerCacheError reason) { |
| 392 DCHECK_EQ(thread_id, CurrentWorkerId()); | 381 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 393 WebServiceWorkerCacheStorage::CacheStorageCallbacks* callbacks = | 382 WebServiceWorkerCacheStorage::CacheStorageCallbacks* callbacks = |
| 394 delete_callbacks_.Lookup(request_id); | 383 delete_callbacks_.Lookup(request_id); |
| 395 callbacks->onError(new blink::WebServiceWorkerCacheError(reason)); | 384 callbacks->onError(reason); |
| 396 delete_callbacks_.Remove(request_id); | 385 delete_callbacks_.Remove(request_id); |
| 397 delete_times_.erase(request_id); | 386 delete_times_.erase(request_id); |
| 398 } | 387 } |
| 399 | 388 |
| 400 void CacheStorageDispatcher::OnCacheStorageKeysError( | 389 void CacheStorageDispatcher::OnCacheStorageKeysError( |
| 401 int thread_id, | 390 int thread_id, |
| 402 int request_id, | 391 int request_id, |
| 403 blink::WebServiceWorkerCacheError reason) { | 392 blink::WebServiceWorkerCacheError reason) { |
| 404 DCHECK_EQ(thread_id, CurrentWorkerId()); | 393 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 405 WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks* callbacks = | 394 WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks* callbacks = |
| 406 keys_callbacks_.Lookup(request_id); | 395 keys_callbacks_.Lookup(request_id); |
| 407 callbacks->onError(new blink::WebServiceWorkerCacheError(reason)); | 396 callbacks->onError(reason); |
| 408 keys_callbacks_.Remove(request_id); | 397 keys_callbacks_.Remove(request_id); |
| 409 keys_times_.erase(request_id); | 398 keys_times_.erase(request_id); |
| 410 } | 399 } |
| 411 | 400 |
| 412 void CacheStorageDispatcher::OnCacheStorageMatchError( | 401 void CacheStorageDispatcher::OnCacheStorageMatchError( |
| 413 int thread_id, | 402 int thread_id, |
| 414 int request_id, | 403 int request_id, |
| 415 blink::WebServiceWorkerCacheError reason) { | 404 blink::WebServiceWorkerCacheError reason) { |
| 416 DCHECK_EQ(thread_id, CurrentWorkerId()); | 405 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 417 WebServiceWorkerCacheStorage::CacheStorageMatchCallbacks* callbacks = | 406 WebServiceWorkerCacheStorage::CacheStorageMatchCallbacks* callbacks = |
| 418 match_callbacks_.Lookup(request_id); | 407 match_callbacks_.Lookup(request_id); |
| 419 callbacks->onError(new blink::WebServiceWorkerCacheError(reason)); | 408 callbacks->onError(reason); |
| 420 match_callbacks_.Remove(request_id); | 409 match_callbacks_.Remove(request_id); |
| 421 match_times_.erase(request_id); | 410 match_times_.erase(request_id); |
| 422 } | 411 } |
| 423 | 412 |
| 424 void CacheStorageDispatcher::OnCacheMatchSuccess( | 413 void CacheStorageDispatcher::OnCacheMatchSuccess( |
| 425 int thread_id, | 414 int thread_id, |
| 426 int request_id, | 415 int request_id, |
| 427 const ServiceWorkerResponse& response) { | 416 const ServiceWorkerResponse& response) { |
| 428 DCHECK_EQ(thread_id, CurrentWorkerId()); | 417 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 429 blink::WebServiceWorkerResponse web_response; | 418 blink::WebServiceWorkerResponse web_response; |
| 430 PopulateWebResponseFromResponse(response, &web_response); | 419 PopulateWebResponseFromResponse(response, &web_response); |
| 431 | 420 |
| 432 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.Match", | 421 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.Match", |
| 433 TimeTicks::Now() - cache_match_times_[request_id]); | 422 TimeTicks::Now() - cache_match_times_[request_id]); |
| 434 blink::WebServiceWorkerCache::CacheMatchCallbacks* callbacks = | 423 blink::WebServiceWorkerCache::CacheMatchCallbacks* callbacks = |
| 435 cache_match_callbacks_.Lookup(request_id); | 424 cache_match_callbacks_.Lookup(request_id); |
| 436 callbacks->onSuccess(&web_response); | 425 callbacks->onSuccess(web_response); |
| 437 cache_match_callbacks_.Remove(request_id); | 426 cache_match_callbacks_.Remove(request_id); |
| 438 cache_match_times_.erase(request_id); | 427 cache_match_times_.erase(request_id); |
| 439 } | 428 } |
| 440 | 429 |
| 441 void CacheStorageDispatcher::OnCacheMatchAllSuccess( | 430 void CacheStorageDispatcher::OnCacheMatchAllSuccess( |
| 442 int thread_id, | 431 int thread_id, |
| 443 int request_id, | 432 int request_id, |
| 444 const std::vector<ServiceWorkerResponse>& responses) { | 433 const std::vector<ServiceWorkerResponse>& responses) { |
| 445 DCHECK_EQ(thread_id, CurrentWorkerId()); | 434 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 446 blink::WebVector<blink::WebServiceWorkerResponse> web_responses = | |
| 447 WebResponsesFromResponses(responses); | |
| 448 | 435 |
| 449 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.MatchAll", | 436 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.MatchAll", |
| 450 TimeTicks::Now() - cache_match_all_times_[request_id]); | 437 TimeTicks::Now() - cache_match_all_times_[request_id]); |
| 451 blink::WebServiceWorkerCache::CacheWithResponsesCallbacks* callbacks = | 438 blink::WebServiceWorkerCache::CacheWithResponsesCallbacks* callbacks = |
| 452 cache_match_all_callbacks_.Lookup(request_id); | 439 cache_match_all_callbacks_.Lookup(request_id); |
| 453 callbacks->onSuccess(&web_responses); | 440 callbacks->onSuccess(WebResponsesFromResponses(responses)); |
| 454 cache_match_all_callbacks_.Remove(request_id); | 441 cache_match_all_callbacks_.Remove(request_id); |
| 455 cache_match_all_times_.erase(request_id); | 442 cache_match_all_times_.erase(request_id); |
| 456 } | 443 } |
| 457 | 444 |
| 458 void CacheStorageDispatcher::OnCacheKeysSuccess( | 445 void CacheStorageDispatcher::OnCacheKeysSuccess( |
| 459 int thread_id, | 446 int thread_id, |
| 460 int request_id, | 447 int request_id, |
| 461 const std::vector<ServiceWorkerFetchRequest>& requests) { | 448 const std::vector<ServiceWorkerFetchRequest>& requests) { |
| 462 DCHECK_EQ(thread_id, CurrentWorkerId()); | 449 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 463 blink::WebVector<blink::WebServiceWorkerRequest> web_requests = | |
| 464 WebRequestsFromRequests(requests); | |
| 465 | 450 |
| 466 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.Keys", | 451 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.Keys", |
| 467 TimeTicks::Now() - cache_keys_times_[request_id]); | 452 TimeTicks::Now() - cache_keys_times_[request_id]); |
| 468 blink::WebServiceWorkerCache::CacheWithRequestsCallbacks* callbacks = | 453 blink::WebServiceWorkerCache::CacheWithRequestsCallbacks* callbacks = |
| 469 cache_keys_callbacks_.Lookup(request_id); | 454 cache_keys_callbacks_.Lookup(request_id); |
| 470 callbacks->onSuccess(&web_requests); | 455 callbacks->onSuccess(WebRequestsFromRequests(requests)); |
| 471 cache_keys_callbacks_.Remove(request_id); | 456 cache_keys_callbacks_.Remove(request_id); |
| 472 cache_keys_times_.erase(request_id); | 457 cache_keys_times_.erase(request_id); |
| 473 } | 458 } |
| 474 | 459 |
| 475 void CacheStorageDispatcher::OnCacheBatchSuccess( | 460 void CacheStorageDispatcher::OnCacheBatchSuccess( |
| 476 int thread_id, | 461 int thread_id, |
| 477 int request_id) { | 462 int request_id) { |
| 478 DCHECK_EQ(thread_id, CurrentWorkerId()); | 463 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 479 | 464 |
| 480 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.Batch", | 465 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.Cache.Batch", |
| 481 TimeTicks::Now() - cache_batch_times_[request_id]); | 466 TimeTicks::Now() - cache_batch_times_[request_id]); |
| 482 blink::WebServiceWorkerCache::CacheBatchCallbacks* callbacks = | 467 blink::WebServiceWorkerCache::CacheBatchCallbacks* callbacks = |
| 483 cache_batch_callbacks_.Lookup(request_id); | 468 cache_batch_callbacks_.Lookup(request_id); |
| 484 callbacks->onSuccess(); | 469 callbacks->onSuccess(); |
| 485 cache_batch_callbacks_.Remove(request_id); | 470 cache_batch_callbacks_.Remove(request_id); |
| 486 cache_batch_times_.erase(request_id); | 471 cache_batch_times_.erase(request_id); |
| 487 } | 472 } |
| 488 | 473 |
| 489 void CacheStorageDispatcher::OnCacheMatchError( | 474 void CacheStorageDispatcher::OnCacheMatchError( |
| 490 int thread_id, | 475 int thread_id, |
| 491 int request_id, | 476 int request_id, |
| 492 blink::WebServiceWorkerCacheError reason) { | 477 blink::WebServiceWorkerCacheError reason) { |
| 493 DCHECK_EQ(thread_id, CurrentWorkerId()); | 478 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 494 blink::WebServiceWorkerCache::CacheMatchCallbacks* callbacks = | 479 blink::WebServiceWorkerCache::CacheMatchCallbacks* callbacks = |
| 495 cache_match_callbacks_.Lookup(request_id); | 480 cache_match_callbacks_.Lookup(request_id); |
| 496 callbacks->onError(new blink::WebServiceWorkerCacheError(reason)); | 481 callbacks->onError(reason); |
| 497 cache_match_callbacks_.Remove(request_id); | 482 cache_match_callbacks_.Remove(request_id); |
| 498 cache_match_times_.erase(request_id); | 483 cache_match_times_.erase(request_id); |
| 499 } | 484 } |
| 500 | 485 |
| 501 void CacheStorageDispatcher::OnCacheMatchAllError( | 486 void CacheStorageDispatcher::OnCacheMatchAllError( |
| 502 int thread_id, | 487 int thread_id, |
| 503 int request_id, | 488 int request_id, |
| 504 blink::WebServiceWorkerCacheError reason) { | 489 blink::WebServiceWorkerCacheError reason) { |
| 505 DCHECK_EQ(thread_id, CurrentWorkerId()); | 490 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 506 blink::WebServiceWorkerCache::CacheWithResponsesCallbacks* callbacks = | 491 blink::WebServiceWorkerCache::CacheWithResponsesCallbacks* callbacks = |
| 507 cache_match_all_callbacks_.Lookup(request_id); | 492 cache_match_all_callbacks_.Lookup(request_id); |
| 508 callbacks->onError(new blink::WebServiceWorkerCacheError(reason)); | 493 callbacks->onError(reason); |
| 509 cache_match_all_callbacks_.Remove(request_id); | 494 cache_match_all_callbacks_.Remove(request_id); |
| 510 cache_match_all_times_.erase(request_id); | 495 cache_match_all_times_.erase(request_id); |
| 511 } | 496 } |
| 512 | 497 |
| 513 void CacheStorageDispatcher::OnCacheKeysError( | 498 void CacheStorageDispatcher::OnCacheKeysError( |
| 514 int thread_id, | 499 int thread_id, |
| 515 int request_id, | 500 int request_id, |
| 516 blink::WebServiceWorkerCacheError reason) { | 501 blink::WebServiceWorkerCacheError reason) { |
| 517 DCHECK_EQ(thread_id, CurrentWorkerId()); | 502 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 518 blink::WebServiceWorkerCache::CacheWithRequestsCallbacks* callbacks = | 503 blink::WebServiceWorkerCache::CacheWithRequestsCallbacks* callbacks = |
| 519 cache_keys_callbacks_.Lookup(request_id); | 504 cache_keys_callbacks_.Lookup(request_id); |
| 520 callbacks->onError(new blink::WebServiceWorkerCacheError(reason)); | 505 callbacks->onError(reason); |
| 521 cache_keys_callbacks_.Remove(request_id); | 506 cache_keys_callbacks_.Remove(request_id); |
| 522 cache_keys_times_.erase(request_id); | 507 cache_keys_times_.erase(request_id); |
| 523 } | 508 } |
| 524 | 509 |
| 525 void CacheStorageDispatcher::OnCacheBatchError( | 510 void CacheStorageDispatcher::OnCacheBatchError( |
| 526 int thread_id, | 511 int thread_id, |
| 527 int request_id, | 512 int request_id, |
| 528 blink::WebServiceWorkerCacheError reason) { | 513 blink::WebServiceWorkerCacheError reason) { |
| 529 DCHECK_EQ(thread_id, CurrentWorkerId()); | 514 DCHECK_EQ(thread_id, CurrentWorkerId()); |
| 530 blink::WebServiceWorkerCache::CacheBatchCallbacks* callbacks = | 515 blink::WebServiceWorkerCache::CacheBatchCallbacks* callbacks = |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 CacheStorageDispatcher::WebResponsesFromResponses( | 663 CacheStorageDispatcher::WebResponsesFromResponses( |
| 679 const std::vector<ServiceWorkerResponse>& responses) { | 664 const std::vector<ServiceWorkerResponse>& responses) { |
| 680 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( | 665 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( |
| 681 responses.size()); | 666 responses.size()); |
| 682 for (size_t i = 0; i < responses.size(); ++i) | 667 for (size_t i = 0; i < responses.size(); ++i) |
| 683 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); | 668 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); |
| 684 return web_responses; | 669 return web_responses; |
| 685 } | 670 } |
| 686 | 671 |
| 687 } // namespace content | 672 } // namespace content |
| OLD | NEW |