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_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 { | |
| 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 | |
| 44 virtual ~StoragePartitionImpl(); | 20 virtual ~StoragePartitionImpl(); |
| 45 | 21 |
| 46 // StoragePartition interface. | 22 // StoragePartition interface. |
| 47 virtual FilePath GetPath() OVERRIDE; | 23 virtual FilePath GetPath() OVERRIDE; |
| 48 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; | 24 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; |
| 49 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; | 25 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; |
| 50 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; | 26 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; |
| 51 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; | 27 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; |
| 52 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; | 28 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
| 53 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; | 29 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; |
| 54 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE; | 30 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE; |
| 55 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; | 31 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; |
| 56 | 32 |
| 57 private: | 33 private: |
| 58 friend class StoragePartitionImplMap; | 34 friend class StoragePartitionImplMap; |
| 59 | 35 |
| 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 | 36 // TODO(ajwong): Break the direct dependency on |context|. We only |
| 76 // need 3 pieces of info from it. | 37 // need 3 pieces of info from it. |
| 77 static StoragePartitionImpl* Create( | 38 static StoragePartitionImpl* Create( |
| 78 BrowserContext* context, | 39 BrowserContext* context, bool in_memory, |
|
nasko
2012/11/08 05:03:54
The second parameter should be on a new line.
awong
2012/11/09 02:51:22
Done.
| |
| 79 const StoragePartitionDescriptor& partition_id, | 40 const FilePath& partition_path); |
|
nasko
2012/11/08 05:03:54
It will be good to put a comment that this is expe
awong
2012/11/09 02:51:22
Done.
| |
| 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 | 41 |
| 88 StoragePartitionImpl( | 42 StoragePartitionImpl( |
| 89 const FilePath& partition_path, | 43 const FilePath& partition_path, |
| 90 quota::QuotaManager* quota_manager, | 44 quota::QuotaManager* quota_manager, |
| 91 ChromeAppCacheService* appcache_service, | 45 ChromeAppCacheService* appcache_service, |
| 92 fileapi::FileSystemContext* filesystem_context, | 46 fileapi::FileSystemContext* filesystem_context, |
| 93 webkit_database::DatabaseTracker* database_tracker, | 47 webkit_database::DatabaseTracker* database_tracker, |
| 94 DOMStorageContextImpl* dom_storage_context, | 48 DOMStorageContextImpl* dom_storage_context, |
| 95 IndexedDBContextImpl* indexed_db_context); | 49 IndexedDBContextImpl* indexed_db_context); |
| 96 | 50 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 119 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 73 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
| 120 scoped_refptr<DOMStorageContextImpl> dom_storage_context_; | 74 scoped_refptr<DOMStorageContextImpl> dom_storage_context_; |
| 121 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; | 75 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
| 122 | 76 |
| 123 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); | 77 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); |
| 124 }; | 78 }; |
| 125 | 79 |
| 126 } // namespace content | 80 } // namespace content |
| 127 | 81 |
| 128 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ | 82 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ |
| OLD | NEW |