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