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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 has_callbacks_.Lookup(request_id); | 289 has_callbacks_.Lookup(request_id); |
290 callbacks->onSuccess(); | 290 callbacks->onSuccess(); |
291 has_callbacks_.Remove(request_id); | 291 has_callbacks_.Remove(request_id); |
292 has_times_.erase(request_id); | 292 has_times_.erase(request_id); |
293 } | 293 } |
294 | 294 |
295 void CacheStorageDispatcher::OnCacheStorageOpenSuccess(int thread_id, | 295 void CacheStorageDispatcher::OnCacheStorageOpenSuccess(int thread_id, |
296 int request_id, | 296 int request_id, |
297 int cache_id) { | 297 int cache_id) { |
298 DCHECK_EQ(thread_id, CurrentWorkerId()); | 298 DCHECK_EQ(thread_id, CurrentWorkerId()); |
299 scoped_ptr<WebCache> web_cache( | 299 std::unique_ptr<WebCache> web_cache( |
300 new WebCache(weak_factory_.GetWeakPtr(), cache_id)); | 300 new WebCache(weak_factory_.GetWeakPtr(), cache_id)); |
301 web_caches_.AddWithID(web_cache.get(), cache_id); | 301 web_caches_.AddWithID(web_cache.get(), cache_id); |
302 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Open", | 302 UMA_HISTOGRAM_TIMES("ServiceWorkerCache.CacheStorage.Open", |
303 TimeTicks::Now() - open_times_[request_id]); | 303 TimeTicks::Now() - open_times_[request_id]); |
304 WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks* callbacks = | 304 WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks* callbacks = |
305 open_callbacks_.Lookup(request_id); | 305 open_callbacks_.Lookup(request_id); |
306 callbacks->onSuccess(std::move(web_cache)); | 306 callbacks->onSuccess(std::move(web_cache)); |
307 open_callbacks_.Remove(request_id); | 307 open_callbacks_.Remove(request_id); |
308 open_times_.erase(request_id); | 308 open_times_.erase(request_id); |
309 } | 309 } |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 CacheStorageDispatcher::WebResponsesFromResponses( | 673 CacheStorageDispatcher::WebResponsesFromResponses( |
674 const std::vector<ServiceWorkerResponse>& responses) { | 674 const std::vector<ServiceWorkerResponse>& responses) { |
675 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( | 675 blink::WebVector<blink::WebServiceWorkerResponse> web_responses( |
676 responses.size()); | 676 responses.size()); |
677 for (size_t i = 0; i < responses.size(); ++i) | 677 for (size_t i = 0; i < responses.size(); ++i) |
678 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); | 678 PopulateWebResponseFromResponse(responses[i], &(web_responses[i])); |
679 return web_responses; | 679 return web_responses; |
680 } | 680 } |
681 | 681 |
682 } // namespace content | 682 } // namespace content |
OLD | NEW |