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

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

Issue 10913265: Redo the Storage Partition directory layout to support guest tags and origin based partitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 years, 3 months 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
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/browser/storage_partition_impl.h" 5 #include "content/browser/storage_partition_impl.h"
6 6
7 #include "content/browser/fileapi/browser_file_system_helper.h" 7 #include "content/browser/fileapi/browser_file_system_helper.h"
8 #include "content/public/browser/browser_context.h" 8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "webkit/database/database_tracker.h" 10 #include "webkit/database/database_tracker.h"
11 #include "webkit/quota/quota_manager.h" 11 #include "webkit/quota/quota_manager.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 namespace {
16
17 // These constants are used to create the directory structure under the profile
18 // where renderers with a non-default storage partition keep their persistent
19 // state. This will contain a set of directories that partially mirror the
20 // directory structure of BrowserContext::GetPath().
21 //
22 // The kStoragePartitionDirname is contains an extensions directory which is
23 // further partitioned by extension id, followed by another level of directories
24 // for the "default" extension storage partition and one directory for each
25 // persistent partition used by an extension's browser tags. Example:
26 //
27 // {kStoragePartitionDirname}/extensions/ABCDEF/default
28 // {kStoragePartitionDirname}/extensions/ABCDEF/{hash(guest partition)}
29 //
30 // The code in GetPartitionPath() constructs these path names.
31 const FilePath::CharType kStoragePartitionDirname[] =
32 FILE_PATH_LITERAL("Storage Partitions");
33 const FilePath::CharType kExtensionsDirname[] =
34 FILE_PATH_LITERAL("extensions");
35 const FilePath::CharType kDefaultPartitionDirname[] =
36 FILE_PATH_LITERAL("default");
37
38 } // namespace
39
40 // static
41 FilePath StoragePartition::GetPartitionPath(const std::string& partition_id) {
42 if (partition_id.empty()) {
43 // The default profile just sits inside the top-level profile directory.
44 return FilePath();
45 }
46
47 // TODO(ajwong): This should check that we create a valid path name.
48 CHECK(IsStringASCII(partition_id));
49 return FilePath(kStoragePartitionDirname)
50 .Append(kExtensionsDirname)
51 .AppendASCII(partition_id)
52 .Append(kDefaultPartitionDirname);
53 }
54
15 StoragePartitionImpl::StoragePartitionImpl( 55 StoragePartitionImpl::StoragePartitionImpl(
16 const FilePath& partition_path, 56 const FilePath& partition_path,
17 quota::QuotaManager* quota_manager, 57 quota::QuotaManager* quota_manager,
18 ChromeAppCacheService* appcache_service, 58 ChromeAppCacheService* appcache_service,
19 fileapi::FileSystemContext* filesystem_context, 59 fileapi::FileSystemContext* filesystem_context,
20 webkit_database::DatabaseTracker* database_tracker, 60 webkit_database::DatabaseTracker* database_tracker,
21 DOMStorageContextImpl* dom_storage_context, 61 DOMStorageContextImpl* dom_storage_context,
22 IndexedDBContextImpl* indexed_db_context) 62 IndexedDBContextImpl* indexed_db_context)
23 : partition_path_(partition_path), 63 : partition_path_(partition_path),
24 quota_manager_(quota_manager), 64 quota_manager_(quota_manager),
(...skipping 15 matching lines...) Expand all
40 } 80 }
41 81
42 if (GetDOMStorageContext()) 82 if (GetDOMStorageContext())
43 GetDOMStorageContext()->Shutdown(); 83 GetDOMStorageContext()->Shutdown();
44 } 84 }
45 85
46 // TODO(ajwong): Break the direct dependency on |context|. We only 86 // TODO(ajwong): Break the direct dependency on |context|. We only
47 // need 3 pieces of info from it. 87 // need 3 pieces of info from it.
48 StoragePartitionImpl* StoragePartitionImpl::Create( 88 StoragePartitionImpl* StoragePartitionImpl::Create(
49 BrowserContext* context, 89 BrowserContext* context,
50 const FilePath& partition_path) { 90 const std::string& partition_id,
91 const FilePath& profile_path) {
51 // Ensure that these methods are called on the UI thread, except for 92 // Ensure that these methods are called on the UI thread, except for
52 // unittests where a UI thread might not have been created. 93 // unittests where a UI thread might not have been created.
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
54 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); 95 !BrowserThread::IsMessageLoopValid(BrowserThread::UI));
55 96
97 FilePath partition_path =
98 profile_path.Append(GetPartitionPath(partition_id));
99
56 // All of the clients have to be created and registered with the 100 // All of the clients have to be created and registered with the
57 // QuotaManager prior to the QuotaManger being used. We do them 101 // QuotaManager prior to the QuotaManger being used. We do them
58 // all together here prior to handing out a reference to anything 102 // all together here prior to handing out a reference to anything
59 // that utilizes the QuotaManager. 103 // that utilizes the QuotaManager.
60 scoped_refptr<quota::QuotaManager> quota_manager = 104 scoped_refptr<quota::QuotaManager> quota_manager =
61 new quota::QuotaManager( 105 new quota::QuotaManager(
62 context->IsOffTheRecord(), partition_path, 106 context->IsOffTheRecord(), partition_path,
63 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), 107 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
64 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), 108 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
65 context->GetSpecialStoragePolicy()); 109 context->GetSpecialStoragePolicy());
(...skipping 26 matching lines...) Expand all
92 136
93 return new StoragePartitionImpl(partition_path, 137 return new StoragePartitionImpl(partition_path,
94 quota_manager, 138 quota_manager,
95 appcache_service, 139 appcache_service,
96 filesystem_context, 140 filesystem_context,
97 database_tracker, 141 database_tracker,
98 dom_storage_context, 142 dom_storage_context,
99 indexed_db_context); 143 indexed_db_context);
100 } 144 }
101 145
146 FilePath StoragePartitionImpl::GetPath() {
147 return partition_path_;
148 }
149
102 quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() { 150 quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() {
103 return quota_manager_; 151 return quota_manager_;
104 } 152 }
105 153
106 ChromeAppCacheService* StoragePartitionImpl::GetAppCacheService() { 154 ChromeAppCacheService* StoragePartitionImpl::GetAppCacheService() {
107 return appcache_service_; 155 return appcache_service_;
108 } 156 }
109 157
110 fileapi::FileSystemContext* StoragePartitionImpl::GetFileSystemContext() { 158 fileapi::FileSystemContext* StoragePartitionImpl::GetFileSystemContext() {
111 return filesystem_context_; 159 return filesystem_context_;
112 } 160 }
113 161
114 webkit_database::DatabaseTracker* StoragePartitionImpl::GetDatabaseTracker() { 162 webkit_database::DatabaseTracker* StoragePartitionImpl::GetDatabaseTracker() {
115 return database_tracker_; 163 return database_tracker_;
116 } 164 }
117 165
118 DOMStorageContextImpl* StoragePartitionImpl::GetDOMStorageContext() { 166 DOMStorageContextImpl* StoragePartitionImpl::GetDOMStorageContext() {
119 return dom_storage_context_; 167 return dom_storage_context_;
120 } 168 }
121 169
122 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { 170 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() {
123 return indexed_db_context_; 171 return indexed_db_context_;
124 } 172 }
125 173
126 } // namespace content 174 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698