Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(834)

Side by Side Diff: content/browser/storage_partition_impl.h

Issue 11366140: Fix on-disk structure for persistent storage in webview tags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/gtest_prod_util.h"
11 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
12 #include "content/browser/appcache/chrome_appcache_service.h" 11 #include "content/browser/appcache/chrome_appcache_service.h"
13 #include "content/browser/dom_storage/dom_storage_context_impl.h" 12 #include "content/browser/dom_storage/dom_storage_context_impl.h"
14 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" 13 #include "content/browser/in_process_webkit/indexed_db_context_impl.h"
15 #include "content/public/browser/storage_partition.h" 14 #include "content/public/browser/storage_partition.h"
16 15
17 namespace content { 16 namespace content {
18 17
19 class StoragePartitionImpl : public StoragePartition { 18 class StoragePartitionImpl : public StoragePartition {
20 public: 19 public:
21 virtual ~StoragePartitionImpl(); 20 virtual ~StoragePartitionImpl();
22 21
23 // StoragePartition interface. 22 // StoragePartition interface.
24 virtual FilePath GetPath() OVERRIDE; 23 virtual FilePath GetPath() OVERRIDE;
25 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; 24 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE;
26 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE; 25 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE;
27 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE; 26 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE;
28 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE; 27 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE;
29 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; 28 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE;
30 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE; 29 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
31 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE; 30 virtual DOMStorageContextImpl* GetDOMStorageContext() OVERRIDE;
32 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE; 31 virtual IndexedDBContextImpl* GetIndexedDBContext() OVERRIDE;
33 32
34 private: 33 private:
35 FRIEND_TEST_ALL_PREFIXES(StoragePartitionConfigTest, OperatorLess);
36 friend class StoragePartitionImplMap; 34 friend class StoragePartitionImplMap;
37 35
38 // Each StoragePartition is uniquely identified by which partition domain 36 // The |partition_path| is the absolute path to the root of this
39 // it belongs to (such as an app or the browser itself), the user supplied 37 // StoragePartition's on-disk storage.
40 // partition name and the bit indicating whether it should be persisted on
41 // disk or not. This structure contains those elements and is used as
42 // uniqueness key to lookup StoragePartition objects in the global map.
43 // 38 //
44 // TODO(nasko): It is equivalent, though not identical to the same structure 39 // If |in_memory| is true, nothing is persisted to disk.
45 // that lives in chrome profiles. The difference is that this one has 40 //
46 // partition_domain and partition_name separate, while the latter one has 41 // TODO(ajwong): Should we assert that the |partition_path| is empty if
47 // the path produced by combining the two pieces together. 42 // in_memory is true.
nasko 2012/11/12 16:47:28 partition_path wouldn't be empty, would it? I thin
awong 2012/11/12 21:36:16 Reworded.
48 // The fix for http://crbug.com/159193 will remove the chrome version. 43 static StoragePartitionImpl* Create(BrowserContext* context,
49 struct StoragePartitionConfig { 44 bool in_memory,
50 const std::string partition_domain; 45 const FilePath& profile_path);
51 const std::string partition_name;
52 const bool in_memory;
53
54 StoragePartitionConfig(const std::string& domain,
55 const std::string& partition,
56 const bool& in_memory_only)
57 : partition_domain(domain),
58 partition_name(partition),
59 in_memory(in_memory_only) {}
60 };
61
62 // Functor for operator <.
63 struct StoragePartitionConfigLess {
64 bool operator()(const StoragePartitionConfig& lhs,
65 const StoragePartitionConfig& rhs) const {
66 if (lhs.partition_domain != rhs.partition_domain)
67 return lhs.partition_domain < rhs.partition_domain;
68 else if (lhs.partition_name != rhs.partition_name)
69 return lhs.partition_name < rhs.partition_name;
70 else if (lhs.in_memory != rhs.in_memory)
71 return lhs.in_memory < rhs.in_memory;
72 else
73 return false;
74 }
75 };
76
77 // TODO(ajwong): Break the direct dependency on |context|. We only
78 // need 3 pieces of info from it.
79 static StoragePartitionImpl* Create(
80 BrowserContext* context,
81 const StoragePartitionConfig& partition_id,
82 const FilePath& profile_path);
83
84 // Returns the relative path from the profile's base directory, to the
85 // directory that holds all the state for storage contexts in
86 // |partition_config|. If any of the strings in |partition_config| contain
87 // embedded nuls, the values will be truncated and only the portion prior to
88 // the nul will be used.
89 static FilePath GetStoragePartitionPath(
90 const StoragePartitionConfig& partition_config);
91 46
92 StoragePartitionImpl( 47 StoragePartitionImpl(
93 const FilePath& partition_path, 48 const FilePath& partition_path,
94 quota::QuotaManager* quota_manager, 49 quota::QuotaManager* quota_manager,
95 ChromeAppCacheService* appcache_service, 50 ChromeAppCacheService* appcache_service,
96 fileapi::FileSystemContext* filesystem_context, 51 fileapi::FileSystemContext* filesystem_context,
97 webkit_database::DatabaseTracker* database_tracker, 52 webkit_database::DatabaseTracker* database_tracker,
98 DOMStorageContextImpl* dom_storage_context, 53 DOMStorageContextImpl* dom_storage_context,
99 IndexedDBContextImpl* indexed_db_context); 54 IndexedDBContextImpl* indexed_db_context);
100 55
(...skipping 22 matching lines...) Expand all
123 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; 78 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
124 scoped_refptr<DOMStorageContextImpl> dom_storage_context_; 79 scoped_refptr<DOMStorageContextImpl> dom_storage_context_;
125 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 80 scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
126 81
127 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl); 82 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImpl);
128 }; 83 };
129 84
130 } // namespace content 85 } // namespace content
131 86
132 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_ 87 #endif // CONTENT_BROWSER_STORAGE_PARTITION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698