| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_STORAGE_PARTITION_MAP_H_ | 5 #ifndef CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ |
| 6 #define CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ | 6 #define CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/hash_tables.h" |
| 13 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 14 #include "content/browser/storage_partition_impl.h" | 15 #include "content/browser/storage_partition_impl.h" |
| 15 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 16 | 17 |
| 17 class FilePath; | 18 class FilePath; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 class BrowserContext; | 22 class BrowserContext; |
| 22 | 23 |
| 23 // A std::string to StoragePartition map for use with SupportsUserData APIs. | 24 // A std::string to StoragePartition map for use with SupportsUserData APIs. |
| 24 class StoragePartitionImplMap : public base::SupportsUserData::Data { | 25 class StoragePartitionImplMap : public base::SupportsUserData::Data { |
| 25 public: | 26 public: |
| 26 explicit StoragePartitionImplMap(BrowserContext* browser_context); | 27 explicit StoragePartitionImplMap(BrowserContext* browser_context); |
| 27 | 28 |
| 28 virtual ~StoragePartitionImplMap(); | 29 virtual ~StoragePartitionImplMap(); |
| 29 | 30 |
| 30 // This map retains ownership of the returned StoragePartition objects. | 31 // This map retains ownership of the returned StoragePartition objects. |
| 31 StoragePartitionImpl* Get(const std::string& partition_domain, | 32 StoragePartitionImpl* Get(const std::string& partition_domain, |
| 32 const std::string& partition_name, | 33 const std::string& partition_name, |
| 33 bool in_memory); | 34 bool in_memory); |
| 34 | 35 |
| 35 // Starts an asynchronous best-effort attempt to delete all on-disk storage | 36 // Starts an asynchronous best-effort attempt to delete all on-disk storage |
| 36 // related to |site|, avoiding any directories that are known to be in use. | 37 // related to |site|, avoiding any directories that are known to be in use. |
| 37 void AsyncObliterate(const GURL& site); | 38 // |
| 39 // |on_gc_required| is called if the AsyncObliterate() call was unable to |
| 40 // fully clean the on-disk storage requiring a call to GarbageCollect() on |
| 41 // the next browser start. |
| 42 void AsyncObliterate(const GURL& site, const base::Closure& on_gc_required); |
| 43 |
| 44 // Examines the on disk storage and removes any entires that are not listed in |
| 45 // the active_paths, or in use by current entires in the storage partition. |
| 46 void GarbageCollect(scoped_ptr<base::hash_set<FilePath> > active_paths, |
| 47 const base::Closure& done); |
| 38 | 48 |
| 39 void ForEach(const BrowserContext::StoragePartitionCallback& callback); | 49 void ForEach(const BrowserContext::StoragePartitionCallback& callback); |
| 40 | 50 |
| 41 private: | 51 private: |
| 42 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess); | 52 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess); |
| 43 | 53 |
| 44 // Each StoragePartition is uniquely identified by which partition domain | 54 // Each StoragePartition is uniquely identified by which partition domain |
| 45 // it belongs to (such as an app or the browser itself), the user supplied | 55 // it belongs to (such as an app or the browser itself), the user supplied |
| 46 // partition name and the bit indicating whether it should be persisted on | 56 // partition name and the bit indicating whether it should be persisted on |
| 47 // disk or not. This structure contains those elements and is used as | 57 // disk or not. This structure contains those elements and is used as |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 PartitionMap partitions_; | 114 PartitionMap partitions_; |
| 105 | 115 |
| 106 // Set to true when the ResourceContext for the associated |browser_context_| | 116 // Set to true when the ResourceContext for the associated |browser_context_| |
| 107 // is initialized. Can never return to false. | 117 // is initialized. Can never return to false. |
| 108 bool resource_context_initialized_; | 118 bool resource_context_initialized_; |
| 109 }; | 119 }; |
| 110 | 120 |
| 111 } // namespace content | 121 } // namespace content |
| 112 | 122 |
| 113 #endif // CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ | 123 #endif // CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ |
| OLD | NEW |