| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREAS_H_ | 5 #ifndef CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREAS_H_ |
| 6 #define CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREAS_H_ | 6 #define CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREAS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "url/origin.h" | 12 #include "url/origin.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class LocalStorageCachedArea; | 15 class LocalStorageCachedArea; |
| 16 |
| 17 namespace mojom { |
| 16 class StoragePartitionService; | 18 class StoragePartitionService; |
| 19 } |
| 17 | 20 |
| 18 // Keeps a map of all the LocalStorageCachedArea objects in a renderer. This is | 21 // Keeps a map of all the LocalStorageCachedArea objects in a renderer. This is |
| 19 // needed because we can have n LocalStorageArea objects for the same origin but | 22 // needed because we can have n LocalStorageArea objects for the same origin but |
| 20 // we want just one LocalStorageCachedArea to service them (no point in having | 23 // we want just one LocalStorageCachedArea to service them (no point in having |
| 21 // multiple caches of the same data in the same process). | 24 // multiple caches of the same data in the same process). |
| 22 class LocalStorageCachedAreas { | 25 class LocalStorageCachedAreas { |
| 23 public: | 26 public: |
| 24 explicit LocalStorageCachedAreas( | 27 explicit LocalStorageCachedAreas( |
| 25 StoragePartitionService* storage_partition_service); | 28 mojom::StoragePartitionService* storage_partition_service); |
| 26 ~LocalStorageCachedAreas(); | 29 ~LocalStorageCachedAreas(); |
| 27 | 30 |
| 28 // Returns, creating if necessary, a cached storage area for the given origin. | 31 // Returns, creating if necessary, a cached storage area for the given origin. |
| 29 scoped_refptr<LocalStorageCachedArea> | 32 scoped_refptr<LocalStorageCachedArea> |
| 30 GetCachedArea(const url::Origin& origin); | 33 GetCachedArea(const url::Origin& origin); |
| 31 | 34 |
| 32 // Called by LocalStorageCachedArea on destruction. | 35 // Called by LocalStorageCachedArea on destruction. |
| 33 void CacheAreaClosed(LocalStorageCachedArea* cached_area); | 36 void CacheAreaClosed(LocalStorageCachedArea* cached_area); |
| 34 | 37 |
| 35 private: | 38 private: |
| 36 StoragePartitionService* const storage_partition_service_; | 39 mojom::StoragePartitionService* const storage_partition_service_; |
| 37 | 40 |
| 38 // Maps from an origin to its LocalStorageCachedArea object. The object owns | 41 // Maps from an origin to its LocalStorageCachedArea object. The object owns |
| 39 // itself. | 42 // itself. |
| 40 std::map<url::Origin, LocalStorageCachedArea*> cached_areas_; | 43 std::map<url::Origin, LocalStorageCachedArea*> cached_areas_; |
| 41 | 44 |
| 42 DISALLOW_COPY_AND_ASSIGN(LocalStorageCachedAreas); | 45 DISALLOW_COPY_AND_ASSIGN(LocalStorageCachedAreas); |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 } // namespace content | 48 } // namespace content |
| 46 | 49 |
| 47 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREAS_H_ | 50 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREAS_H_ |
| OLD | NEW |