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/browser/cache_storage/cache_storage.h" | 5 #include "content/browser/cache_storage/cache_storage.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <set> | 9 #include <set> |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/barrier_closure.h" | 12 #include "base/barrier_closure.h" |
11 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
12 #include "base/files/memory_mapped_file.h" | 14 #include "base/files/memory_mapped_file.h" |
13 #include "base/guid.h" | 15 #include "base/guid.h" |
14 #include "base/location.h" | 16 #include "base/location.h" |
15 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
16 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 return; | 566 return; |
565 } | 567 } |
566 | 568 |
567 base::Closure pending_callback = base::Bind( | 569 base::Closure pending_callback = base::Bind( |
568 &CacheStorage::PendingClosure, weak_factory_.GetWeakPtr(), callback); | 570 &CacheStorage::PendingClosure, weak_factory_.GetWeakPtr(), callback); |
569 scheduler_->ScheduleOperation(base::Bind(&CacheStorage::CloseAllCachesImpl, | 571 scheduler_->ScheduleOperation(base::Bind(&CacheStorage::CloseAllCachesImpl, |
570 weak_factory_.GetWeakPtr(), | 572 weak_factory_.GetWeakPtr(), |
571 pending_callback)); | 573 pending_callback)); |
572 } | 574 } |
573 | 575 |
574 int64 CacheStorage::MemoryBackedSize() const { | 576 int64_t CacheStorage::MemoryBackedSize() const { |
575 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 577 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
576 | 578 |
577 if (!initialized_ || !memory_only_) | 579 if (!initialized_ || !memory_only_) |
578 return 0; | 580 return 0; |
579 | 581 |
580 int64 sum = 0; | 582 int64_t sum = 0; |
581 for (auto& key_value : cache_map_) { | 583 for (auto& key_value : cache_map_) { |
582 if (key_value.second) | 584 if (key_value.second) |
583 sum += key_value.second->MemoryBackedSize(); | 585 sum += key_value.second->MemoryBackedSize(); |
584 } | 586 } |
585 return sum; | 587 return sum; |
586 } | 588 } |
587 | 589 |
588 void CacheStorage::StartAsyncOperationForTesting() { | 590 void CacheStorage::StartAsyncOperationForTesting() { |
589 scheduler_->ScheduleOperation(base::Bind(&base::DoNothing)); | 591 scheduler_->ScheduleOperation(base::Bind(&base::DoNothing)); |
590 } | 592 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 scoped_ptr<ServiceWorkerResponse> response, | 969 scoped_ptr<ServiceWorkerResponse> response, |
968 scoped_ptr<storage::BlobDataHandle> blob_data_handle) { | 970 scoped_ptr<storage::BlobDataHandle> blob_data_handle) { |
969 base::WeakPtr<CacheStorage> cache_storage = weak_factory_.GetWeakPtr(); | 971 base::WeakPtr<CacheStorage> cache_storage = weak_factory_.GetWeakPtr(); |
970 | 972 |
971 callback.Run(error, response.Pass(), blob_data_handle.Pass()); | 973 callback.Run(error, response.Pass(), blob_data_handle.Pass()); |
972 if (cache_storage) | 974 if (cache_storage) |
973 scheduler_->CompleteOperationAndRunNext(); | 975 scheduler_->CompleteOperationAndRunNext(); |
974 } | 976 } |
975 | 977 |
976 } // namespace content | 978 } // namespace content |
OLD | NEW |