| 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/hash_tables.h" |
| 14 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
| 15 #include "content/browser/storage_partition_impl.h" | 15 #include "content/browser/storage_partition_impl.h" |
| 16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 17 | 17 |
| 18 namespace base { |
| 18 class FilePath; | 19 class FilePath; |
| 19 | |
| 20 namespace base { | |
| 21 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 22 } // namespace base | 21 } // namespace base |
| 23 | 22 |
| 24 namespace content { | 23 namespace content { |
| 25 | 24 |
| 26 class BrowserContext; | 25 class BrowserContext; |
| 27 | 26 |
| 28 // A std::string to StoragePartition map for use with SupportsUserData APIs. | 27 // A std::string to StoragePartition map for use with SupportsUserData APIs. |
| 29 class StoragePartitionImplMap : public base::SupportsUserData::Data { | 28 class StoragePartitionImplMap : public base::SupportsUserData::Data { |
| 30 public: | 29 public: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 44 // fully clean the on-disk storage requiring a call to GarbageCollect() on | 43 // fully clean the on-disk storage requiring a call to GarbageCollect() on |
| 45 // the next browser start. | 44 // the next browser start. |
| 46 void AsyncObliterate(const GURL& site, const base::Closure& on_gc_required); | 45 void AsyncObliterate(const GURL& site, const base::Closure& on_gc_required); |
| 47 | 46 |
| 48 // Examines the on-disk storage and removes any entires that are not listed | 47 // Examines the on-disk storage and removes any entires that are not listed |
| 49 // in the |active_paths|, or in use by current entries in the storage | 48 // in the |active_paths|, or in use by current entries in the storage |
| 50 // partition. | 49 // partition. |
| 51 // | 50 // |
| 52 // The |done| closure is executed on the calling thread when garbage | 51 // The |done| closure is executed on the calling thread when garbage |
| 53 // collection is complete. | 52 // collection is complete. |
| 54 void GarbageCollect(scoped_ptr<base::hash_set<FilePath> > active_paths, | 53 void GarbageCollect(scoped_ptr<base::hash_set<base::FilePath> > active_paths, |
| 55 const base::Closure& done); | 54 const base::Closure& done); |
| 56 | 55 |
| 57 void ForEach(const BrowserContext::StoragePartitionCallback& callback); | 56 void ForEach(const BrowserContext::StoragePartitionCallback& callback); |
| 58 | 57 |
| 59 private: | 58 private: |
| 60 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess); | 59 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess); |
| 61 | 60 |
| 62 // Each StoragePartition is uniquely identified by which partition domain | 61 // Each StoragePartition is uniquely identified by which partition domain |
| 63 // it belongs to (such as an app or the browser itself), the user supplied | 62 // it belongs to (such as an app or the browser itself), the user supplied |
| 64 // partition name and the bit indicating whether it should be persisted on | 63 // partition name and the bit indicating whether it should be persisted on |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 typedef std::map<StoragePartitionConfig, | 100 typedef std::map<StoragePartitionConfig, |
| 102 StoragePartitionImpl*, | 101 StoragePartitionImpl*, |
| 103 StoragePartitionConfigLess> | 102 StoragePartitionConfigLess> |
| 104 PartitionMap; | 103 PartitionMap; |
| 105 | 104 |
| 106 // Returns the relative path from the profile's base directory, to the | 105 // Returns the relative path from the profile's base directory, to the |
| 107 // directory that holds all the state for storage contexts in the given | 106 // directory that holds all the state for storage contexts in the given |
| 108 // |partition_domain| and |partition_name|. | 107 // |partition_domain| and |partition_name|. |
| 109 static FilePath GetStoragePartitionPath(const std::string& partition_domain, | 108 static base::FilePath GetStoragePartitionPath( |
| 110 const std::string& partition_name); | 109 const std::string& partition_domain, |
| 110 const std::string& partition_name); |
| 111 | 111 |
| 112 // This must always be called *after* |partition| has been added to the | 112 // This must always be called *after* |partition| has been added to the |
| 113 // partitions_. | 113 // partitions_. |
| 114 // | 114 // |
| 115 // TODO(ajwong): Is there a way to make it so that Get()'s implementation | 115 // TODO(ajwong): Is there a way to make it so that Get()'s implementation |
| 116 // doesn't need to be aware of this ordering? Revisit when refactoring | 116 // doesn't need to be aware of this ordering? Revisit when refactoring |
| 117 // ResourceContext and AppCache to respect storage partitions. | 117 // ResourceContext and AppCache to respect storage partitions. |
| 118 void PostCreateInitialization(StoragePartitionImpl* partition, | 118 void PostCreateInitialization(StoragePartitionImpl* partition, |
| 119 bool in_memory); | 119 bool in_memory); |
| 120 | 120 |
| 121 BrowserContext* browser_context_; // Not Owned. | 121 BrowserContext* browser_context_; // Not Owned. |
| 122 scoped_refptr<base::SequencedTaskRunner> file_access_runner_; | 122 scoped_refptr<base::SequencedTaskRunner> file_access_runner_; |
| 123 PartitionMap partitions_; | 123 PartitionMap partitions_; |
| 124 | 124 |
| 125 // Set to true when the ResourceContext for the associated |browser_context_| | 125 // Set to true when the ResourceContext for the associated |browser_context_| |
| 126 // is initialized. Can never return to false. | 126 // is initialized. Can never return to false. |
| 127 bool resource_context_initialized_; | 127 bool resource_context_initialized_; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 } // namespace content | 130 } // namespace content |
| 131 | 131 |
| 132 #endif // CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ | 132 #endif // CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ |
| OLD | NEW |