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 // Note: It is equivalent, though not identical to the same structure that | |
27 // 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. | |
awong
2012/11/02 21:56:13
Cite bug 159193 as the fix for this forkage.
nasko
2012/11/03 00:36:24
Done.
| |
30 struct StoragePartitionDescriptor { | |
31 const std::string partition_domain; | |
32 const std::string partition_name; | |
33 const bool in_memory; | |
34 | |
35 StoragePartitionDescriptor(const std::string& domain, | |
36 const std::string& partition, | |
37 const bool& in_memory_only) | |
38 : partition_domain(domain), | |
39 partition_name(partition), | |
40 in_memory(in_memory_only) {} | |
41 }; | |
awong
2012/11/02 21:56:13
need newline.
nasko
2012/11/03 00:36:24
Done.
| |
42 // Functor for operator <. | |
43 struct StoragePartitionDescriptorLess { | |
awong
2012/11/02 21:56:13
Can this type be private?
nasko
2012/11/03 00:36:24
Done.
| |
44 bool operator()(const StoragePartitionDescriptor& lhs, | |
45 const StoragePartitionDescriptor& rhs) const { | |
46 if (lhs.partition_domain != rhs.partition_domain) | |
47 return lhs.partition_domain < rhs.partition_domain; | |
48 else if (lhs.partition_name != rhs.partition_name) | |
49 return lhs.partition_name < rhs.partition_name; | |
50 else if (lhs.in_memory != rhs.in_memory) | |
51 return lhs.in_memory < rhs.in_memory; | |
52 else | |
53 return false; | |
54 } | |
55 }; | |
56 | |
20 virtual ~StoragePartitionImpl(); | 57 virtual ~StoragePartitionImpl(); |
21 | 58 |
22 // TODO(ajwong): Break the direct dependency on |context|. We only | 59 // TODO(ajwong): Break the direct dependency on |context|. We only |
23 // need 3 pieces of info from it. | 60 // need 3 pieces of info from it. |
24 static StoragePartitionImpl* Create(BrowserContext* context, | 61 static StoragePartitionImpl* Create( |
25 const std::string& partition_id, | 62 BrowserContext* context, |
26 const FilePath& profile_path); | 63 const StoragePartitionDescriptor& partition_id, |
awong
2012/11/02 21:56:13
What's your thoughts on hiding the Descriptor stru
nasko
2012/11/03 00:36:24
Create is only called by SPIM::Get, so it is not r
| |
64 const FilePath& profile_path); | |
27 | 65 |
28 // StoragePartition interface. | 66 // StoragePartition interface. |
29 virtual FilePath GetPath() OVERRIDE; | 67 virtual FilePath GetPath() OVERRIDE; |
30 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; | 68 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; |
31 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; | 69 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; |
32 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; | 70 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; |
33 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; | 71 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; |
34 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; | 72 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
35 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; | 73 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; |
36 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE; | 74 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE; |
37 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; | 75 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; |
38 | 76 |
39 private: | 77 private: |
40 friend class StoragePartitionImplMap; | 78 friend class StoragePartitionImplMap; |
41 | 79 |
80 // Returns the relative path from the profile's base directory, to the | |
81 // directory that holds all the state for storage contexts in | |
82 // |partition_descriptor|. | |
83 static FilePath GetStoragePartitionPath( | |
84 const StoragePartitionDescriptor& partition_descriptor); | |
85 | |
42 StoragePartitionImpl( | 86 StoragePartitionImpl( |
43 const FilePath& partition_path, | 87 const FilePath& partition_path, |
44 quota::QuotaManager* quota_manager, | 88 quota::QuotaManager* quota_manager, |
45 ChromeAppCacheService* appcache_service, | 89 ChromeAppCacheService* appcache_service, |
46 fileapi::FileSystemContext* filesystem_context, | 90 fileapi::FileSystemContext* filesystem_context, |
47 webkit_database::DatabaseTracker* database_tracker, | 91 webkit_database::DatabaseTracker* database_tracker, |
48 DOMStorageContextImpl* dom_storage_context, | 92 DOMStorageContextImpl* dom_storage_context, |
49 IndexedDBContextImpl* indexed_db_context); | 93 IndexedDBContextImpl* indexed_db_context); |
50 | 94 |
51 // Used by StoragePartitionImplMap. | 95 // Used by StoragePartitionImplMap. |
(...skipping 21 matching lines...) Expand all Loading... | |
73 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 117 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
74 scoped_refptr<DOMStorageContextImpl> dom_storage_context_; | 118 scoped_refptr<DOMStorageContextImpl> dom_storage_context_; |
75 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; | 119 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
76 | 120 |
77 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); | 121 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); |
78 }; | 122 }; |
79 | 123 |
80 } // namespace content | 124 } // namespace content |
81 | 125 |
82 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ | 126 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
OLD | NEW |