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_H_ | 5 #ifndef CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
6 #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ | 6 #define CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "content/browser/appcache/chrome_appcache_service.h" | 11 #include "content/browser/appcache/chrome_appcache_service.h" |
12 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 12 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
13 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 13 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
14 #include "content/public/browser/storage_partition.h" | 14 #include "content/public/browser/storage_partition.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 class StoragePartitionImpl : public StoragePartition { | 18 class StoragePartitionImpl : public StoragePartition { |
19 public: | 19 public: |
20 // Each StoragePartition is uniquely identified by which partition domain | |
21 // it belongs to (such as an app or the browser itself), the user supplied | |
22 // partition name and the bit indicating whether it should be persisted on | |
23 // disk or not. This structure contains those elements and is used as | |
24 // uniqueness key to lookup StoragePartition objects in the global map. | |
25 // | |
26 // TODO(nasko): It is equivalent, though not identical to the same structure | |
27 // that lives in chrome profiles. The difference is that this one has | |
28 // partition_domain and partition_name separate, while the latter one has | |
29 // the path produced by combining the two pieces together. | |
30 // The fix for http://crbug.com/159193 will remove the chrome version. | |
31 struct StoragePartitionDescriptor { | |
Charlie Reis
2012/11/07 02:36:34
Sorry, more name questions. Is this intentionally
nasko
2012/11/07 17:47:01
Done.
| |
32 const std::string partition_domain; | |
33 const std::string partition_name; | |
34 const bool in_memory; | |
35 | |
36 StoragePartitionDescriptor(const std::string& domain, | |
37 const std::string& partition, | |
38 const bool& in_memory_only) | |
39 : partition_domain(domain), | |
40 partition_name(partition), | |
41 in_memory(in_memory_only) {} | |
42 }; | |
43 | |
20 virtual ~StoragePartitionImpl(); | 44 virtual ~StoragePartitionImpl(); |
21 | 45 |
22 // TODO(ajwong): Break the direct dependency on |context|. We only | |
23 // need 3 pieces of info from it. | |
24 static StoragePartitionImpl* Create(BrowserContext* context, | |
25 const std::string& partition_id, | |
26 const FilePath& profile_path); | |
27 | |
28 // StoragePartition interface. | 46 // StoragePartition interface. |
29 virtual FilePath GetPath() OVERRIDE; | 47 virtual FilePath GetPath() OVERRIDE; |
30 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; | 48 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; |
31 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; | 49 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; |
32 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; | 50 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; |
33 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; | 51 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; |
34 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; | 52 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
35 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; | 53 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; |
36 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE; | 54 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE; |
37 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; | 55 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; |
38 | 56 |
39 private: | 57 private: |
40 friend class StoragePartitionImplMap; | 58 friend class StoragePartitionImplMap; |
41 | 59 |
60 // Functor for operator <. | |
61 struct StoragePartitionDescriptorLess { | |
62 bool operator()(const StoragePartitionDescriptor& lhs, | |
63 const StoragePartitionDescriptor& rhs) const { | |
64 if (lhs.partition_domain != rhs.partition_domain) | |
65 return lhs.partition_domain < rhs.partition_domain; | |
66 else if (lhs.partition_name != rhs.partition_name) | |
67 return lhs.partition_name < rhs.partition_name; | |
68 else if (lhs.in_memory != rhs.in_memory) | |
69 return lhs.in_memory < rhs.in_memory; | |
70 else | |
71 return false; | |
72 } | |
73 }; | |
74 | |
75 // TODO(ajwong): Break the direct dependency on |context|. We only | |
76 // need 3 pieces of info from it. | |
77 static StoragePartitionImpl* Create( | |
78 BrowserContext* context, | |
79 const StoragePartitionDescriptor& partition_id, | |
80 const FilePath& profile_path); | |
81 | |
82 // Returns the relative path from the profile's base directory, to the | |
83 // directory that holds all the state for storage contexts in | |
84 // |partition_descriptor|. | |
85 static FilePath GetStoragePartitionPath( | |
86 const StoragePartitionDescriptor& partition_descriptor); | |
87 | |
42 StoragePartitionImpl( | 88 StoragePartitionImpl( |
43 const FilePath& partition_path, | 89 const FilePath& partition_path, |
44 quota::QuotaManager* quota_manager, | 90 quota::QuotaManager* quota_manager, |
45 ChromeAppCacheService* appcache_service, | 91 ChromeAppCacheService* appcache_service, |
46 fileapi::FileSystemContext* filesystem_context, | 92 fileapi::FileSystemContext* filesystem_context, |
47 webkit_database::DatabaseTracker* database_tracker, | 93 webkit_database::DatabaseTracker* database_tracker, |
48 DOMStorageContextImpl* dom_storage_context, | 94 DOMStorageContextImpl* dom_storage_context, |
49 IndexedDBContextImpl* indexed_db_context); | 95 IndexedDBContextImpl* indexed_db_context); |
50 | 96 |
51 // Used by StoragePartitionImplMap. | 97 // Used by StoragePartitionImplMap. |
(...skipping 21 matching lines...) Expand all Loading... | |
73 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 119 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
74 scoped_refptr<DOMStorageContextImpl> dom_storage_context_; | 120 scoped_refptr<DOMStorageContextImpl> dom_storage_context_; |
75 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; | 121 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
76 | 122 |
77 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); | 123 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); |
78 }; | 124 }; |
79 | 125 |
80 } // namespace content | 126 } // namespace content |
81 | 127 |
82 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ | 128 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
OLD | NEW |