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_IMPL_MAP_H_ | 5 #ifndef CONTENT_BROWSER_STORAGE_PARTITION_IMPL_MAP_H_ |
6 #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_MAP_H_ | 6 #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_MAP_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
12 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" |
14 #include "base/supports_user_data.h" | 16 #include "base/supports_user_data.h" |
15 #include "content/browser/storage_partition_impl.h" | 17 #include "content/browser/storage_partition_impl.h" |
16 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
17 | 19 |
18 namespace base { | 20 namespace base { |
19 class FilePath; | 21 class FilePath; |
20 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
21 } // namespace base | 23 } // namespace base |
22 | 24 |
23 namespace content { | 25 namespace content { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 else if (lhs.partition_name != rhs.partition_name) | 96 else if (lhs.partition_name != rhs.partition_name) |
95 return lhs.partition_name < rhs.partition_name; | 97 return lhs.partition_name < rhs.partition_name; |
96 else if (lhs.in_memory != rhs.in_memory) | 98 else if (lhs.in_memory != rhs.in_memory) |
97 return lhs.in_memory < rhs.in_memory; | 99 return lhs.in_memory < rhs.in_memory; |
98 else | 100 else |
99 return false; | 101 return false; |
100 } | 102 } |
101 }; | 103 }; |
102 | 104 |
103 typedef std::map<StoragePartitionConfig, | 105 typedef std::map<StoragePartitionConfig, |
104 StoragePartitionImpl*, | 106 std::unique_ptr<StoragePartitionImpl>, |
105 StoragePartitionConfigLess> | 107 StoragePartitionConfigLess> |
106 PartitionMap; | 108 PartitionMap; |
107 | 109 |
108 // Returns the relative path from the profile's base directory, to the | 110 // Returns the relative path from the profile's base directory, to the |
109 // directory that holds all the state for storage contexts in the given | 111 // directory that holds all the state for storage contexts in the given |
110 // |partition_domain| and |partition_name|. | 112 // |partition_domain| and |partition_name|. |
111 static base::FilePath GetStoragePartitionPath( | 113 static base::FilePath GetStoragePartitionPath( |
112 const std::string& partition_domain, | 114 const std::string& partition_domain, |
113 const std::string& partition_name); | 115 const std::string& partition_name); |
114 | 116 |
115 // This must always be called *after* |partition| has been added to the | 117 // This must always be called *after* |partition| has been added to the |
116 // partitions_. | 118 // partitions_. |
117 // | 119 // |
118 // TODO(ajwong): Is there a way to make it so that Get()'s implementation | 120 // TODO(ajwong): Is there a way to make it so that Get()'s implementation |
119 // doesn't need to be aware of this ordering? Revisit when refactoring | 121 // doesn't need to be aware of this ordering? Revisit when refactoring |
120 // ResourceContext and AppCache to respect storage partitions. | 122 // ResourceContext and AppCache to respect storage partitions. |
121 void PostCreateInitialization(StoragePartitionImpl* partition, | 123 void PostCreateInitialization(StoragePartitionImpl* partition, |
122 bool in_memory); | 124 bool in_memory); |
123 | 125 |
124 BrowserContext* browser_context_; // Not Owned. | 126 BrowserContext* browser_context_; // Not Owned. |
125 scoped_refptr<base::SequencedTaskRunner> file_access_runner_; | 127 scoped_refptr<base::SequencedTaskRunner> file_access_runner_; |
126 PartitionMap partitions_; | 128 PartitionMap partitions_; |
127 | 129 |
128 // Set to true when the ResourceContext for the associated |browser_context_| | 130 // Set to true when the ResourceContext for the associated |browser_context_| |
129 // is initialized. Can never return to false. | 131 // is initialized. Can never return to false. |
130 bool resource_context_initialized_; | 132 bool resource_context_initialized_; |
| 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImplMap); |
131 }; | 135 }; |
132 | 136 |
133 } // namespace content | 137 } // namespace content |
134 | 138 |
135 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_MAP_H_ | 139 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_MAP_H_ |
OLD | NEW |