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 class StoragePartitionService; | 16 class StoragePartitionService; |
17 | 17 |
18 // Owns all the LocalStorageCachedArea objects in a renderer. This is needed | 18 // Keeps a map of all the LocalStorageCachedArea objects in a renderer. This is |
19 // because we can have n LocalStorageArea objects for the same origin but we | 19 // needed because we can have n LocalStorageArea objects for the same origin but |
20 // want just one LocalStorageCachedArea to service them (no point in having | 20 // we want just one LocalStorageCachedArea to service them (no point in having |
21 // multiple caches of the same data in the same process). | 21 // multiple caches of the same data in the same process). |
22 class LocalStorageCachedAreas { | 22 class LocalStorageCachedAreas { |
23 public: | 23 public: |
24 explicit LocalStorageCachedAreas( | 24 explicit LocalStorageCachedAreas( |
25 StoragePartitionService* storage_partition_service); | 25 StoragePartitionService* storage_partition_service); |
26 ~LocalStorageCachedAreas(); | 26 ~LocalStorageCachedAreas(); |
27 | 27 |
28 scoped_refptr<LocalStorageCachedArea> GetLocalStorageCachedArea( | 28 // Returns, creating if necessary, a cached storage area for the given origin. |
29 const url::Origin& origin); | 29 scoped_refptr<LocalStorageCachedArea> |
| 30 GetCachedArea(const url::Origin& origin); |
30 | 31 |
31 // Called by LocalStorageCachedArea on destruction. | 32 // Called by LocalStorageCachedArea on destruction. |
32 void LocalStorageCacheAreaClosed(LocalStorageCachedArea* cached_area); | 33 void CacheAreaClosed(LocalStorageCachedArea* cached_area); |
33 | 34 |
34 private: | 35 private: |
35 StoragePartitionService* const storage_partition_service_; | 36 StoragePartitionService* const storage_partition_service_; |
36 | 37 |
37 // Maps from an origin to its LocalStorageCachedArea object. The object owns | 38 // Maps from an origin to its LocalStorageCachedArea object. The object owns |
38 // itself. | 39 // itself. |
39 std::map<url::Origin, LocalStorageCachedArea*> cached_areas_; | 40 std::map<url::Origin, LocalStorageCachedArea*> cached_areas_; |
40 | 41 |
41 DISALLOW_COPY_AND_ASSIGN(LocalStorageCachedAreas); | 42 DISALLOW_COPY_AND_ASSIGN(LocalStorageCachedAreas); |
42 }; | 43 }; |
43 | 44 |
44 } // namespace content | 45 } // namespace content |
45 | 46 |
46 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREAS_H_ | 47 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREAS_H_ |
OLD | NEW |