Chromium Code Reviews| 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 |
| 20 namespace base { | |
| 21 class SequencedTaskRunner; | |
| 22 } // namespace base | |
| 23 | |
| 19 namespace content { | 24 namespace content { |
| 20 | 25 |
| 21 class BrowserContext; | 26 class BrowserContext; |
| 22 | 27 |
| 23 // A std::string to StoragePartition map for use with SupportsUserData APIs. | 28 // A std::string to StoragePartition map for use with SupportsUserData APIs. |
| 24 class StoragePartitionImplMap : public base::SupportsUserData::Data { | 29 class StoragePartitionImplMap : public base::SupportsUserData::Data { |
| 25 public: | 30 public: |
| 26 explicit StoragePartitionImplMap(BrowserContext* browser_context); | 31 explicit StoragePartitionImplMap(BrowserContext* browser_context); |
| 27 | 32 |
| 28 virtual ~StoragePartitionImplMap(); | 33 virtual ~StoragePartitionImplMap(); |
| 29 | 34 |
| 30 // This map retains ownership of the returned StoragePartition objects. | 35 // This map retains ownership of the returned StoragePartition objects. |
| 31 StoragePartitionImpl* Get(const std::string& partition_domain, | 36 StoragePartitionImpl* Get(const std::string& partition_domain, |
| 32 const std::string& partition_name, | 37 const std::string& partition_name, |
| 33 bool in_memory); | 38 bool in_memory); |
| 34 | 39 |
| 35 // Starts an asynchronous best-effort attempt to delete all on-disk storage | 40 // 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. | 41 // related to |site|, avoiding any directories that are known to be in use. |
| 37 void AsyncObliterate(const GURL& site); | 42 // |
| 43 // |on_gc_required| is called if the AsyncObliterate() call was unable to | |
| 44 // fully clean the on-disk storage requiring a call to GarbageCollect() on | |
| 45 // the next browser start. | |
| 46 void AsyncObliterate(const GURL& site, const base::Closure& on_gc_required); | |
| 47 | |
| 48 // Examines the on disk storage and removes any entires that are not listed in | |
|
Charlie Reis
2012/12/10 23:22:28
nit: on-disk
awong
2012/12/11 01:18:32
Done.
| |
| 49 // the active_paths, or in use by current entires in the storage partition. | |
|
Charlie Reis
2012/12/10 23:22:28
nit: entries
Can you also mention that the done c
awong
2012/12/11 01:18:32
Done.
| |
| 50 void GarbageCollect(scoped_ptr<base::hash_set<FilePath> > active_paths, | |
| 51 const base::Closure& done); | |
| 38 | 52 |
| 39 void ForEach(const BrowserContext::StoragePartitionCallback& callback); | 53 void ForEach(const BrowserContext::StoragePartitionCallback& callback); |
| 40 | 54 |
| 41 private: | 55 private: |
| 42 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess); | 56 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess); |
| 43 | 57 |
| 44 // Each StoragePartition is uniquely identified by which partition domain | 58 // Each StoragePartition is uniquely identified by which partition domain |
| 45 // it belongs to (such as an app or the browser itself), the user supplied | 59 // 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 | 60 // 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 | 61 // disk or not. This structure contains those elements and is used as |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 // This must always be called *after* |partition| has been added to the | 108 // This must always be called *after* |partition| has been added to the |
| 95 // partitions_. | 109 // partitions_. |
| 96 // | 110 // |
| 97 // TODO(ajwong): Is there a way to make it so that Get()'s implementation | 111 // TODO(ajwong): Is there a way to make it so that Get()'s implementation |
| 98 // doesn't need to be aware of this ordering? Revisit when refactoring | 112 // doesn't need to be aware of this ordering? Revisit when refactoring |
| 99 // ResourceContext and AppCache to respect storage partitions. | 113 // ResourceContext and AppCache to respect storage partitions. |
| 100 void PostCreateInitialization(StoragePartitionImpl* partition, | 114 void PostCreateInitialization(StoragePartitionImpl* partition, |
| 101 bool in_memory); | 115 bool in_memory); |
| 102 | 116 |
| 103 BrowserContext* browser_context_; // Not Owned. | 117 BrowserContext* browser_context_; // Not Owned. |
| 118 scoped_refptr<base::SequencedTaskRunner> file_access_runner_; | |
| 104 PartitionMap partitions_; | 119 PartitionMap partitions_; |
| 105 | 120 |
| 106 // Set to true when the ResourceContext for the associated |browser_context_| | 121 // Set to true when the ResourceContext for the associated |browser_context_| |
| 107 // is initialized. Can never return to false. | 122 // is initialized. Can never return to false. |
| 108 bool resource_context_initialized_; | 123 bool resource_context_initialized_; |
| 109 }; | 124 }; |
| 110 | 125 |
| 111 } // namespace content | 126 } // namespace content |
| 112 | 127 |
| 113 #endif // CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ | 128 #endif // CONTENT_BROWSER_STORAGE_PARTITION_MAP_H_ |
| OLD | NEW |