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

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

Issue 11234032: Webview tag creation should be using storage partitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added IndexedDB test. 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 #include "content/browser/storage_partition_impl.h" 5 #include "content/browser/storage_partition_impl.h"
6 6
7 #include "base/utf_string_conversions.h"
7 #include "content/browser/fileapi/browser_file_system_helper.h" 8 #include "content/browser/fileapi/browser_file_system_helper.h"
8 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
10 #include "net/url_request/url_request_context_getter.h" 11 #include "net/url_request/url_request_context_getter.h"
11 #include "webkit/database/database_tracker.h" 12 #include "webkit/database/database_tracker.h"
12 #include "webkit/quota/quota_manager.h" 13 #include "webkit/quota/quota_manager.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 namespace { 17 namespace {
(...skipping 15 matching lines...) Expand all
32 const FilePath::CharType kStoragePartitionDirname[] = 33 const FilePath::CharType kStoragePartitionDirname[] =
33 FILE_PATH_LITERAL("Storage"); 34 FILE_PATH_LITERAL("Storage");
34 const FilePath::CharType kExtensionsDirname[] = 35 const FilePath::CharType kExtensionsDirname[] =
35 FILE_PATH_LITERAL("ext"); 36 FILE_PATH_LITERAL("ext");
36 const FilePath::CharType kDefaultPartitionDirname[] = 37 const FilePath::CharType kDefaultPartitionDirname[] =
37 FILE_PATH_LITERAL("def"); 38 FILE_PATH_LITERAL("def");
38 39
39 } // namespace 40 } // namespace
40 41
41 // static 42 // static
42 FilePath StoragePartition::GetPartitionPath(const std::string& partition_id) { 43 FilePath StoragePartitionImpl::GetStoragePartitionPath(
43 if (partition_id.empty()) { 44 const StoragePartitionDescriptor& descriptor) {
44 // The default profile just sits inside the top-level profile directory. 45 if (descriptor.partition_domain.empty())
45 return FilePath(); 46 return FilePath();
47
48 #if defined(OS_POSIX)
49 FilePath::StringType domain = descriptor.partition_domain;
awong 2012/11/02 21:56:13 Do we know if partition_domain, etc., are UTF-8?
nasko 2012/11/03 00:36:24 Yes, the partition_domain is even ASCII, since it
awong 2012/11/05 18:00:33 Do we have a check that enforces ascii and is it i
50 FilePath::StringType name = descriptor.partition_name;
51 #elif defined(OS_WIN)
52 FilePath::StringType domain = UTF8ToUTF16(descriptor.partition_domain);
53 FilePath::StringType name = UTF8ToUTF16(descriptor.partition_name);
54 #endif // OS_WIN
55
56 FilePath path = FilePath(kStoragePartitionDirname).Append(kExtensionsDirname)
57 .Append(domain);
58 if (!name.empty()) {
59 return path.Append(name);
60 } else {
61 return path.Append(kDefaultPartitionDirname);
awong 2012/11/02 21:56:13 Drop this out of the else {} clause and remove the
nasko 2012/11/03 00:36:24 Done.
46 } 62 }
47 63
48 // TODO(ajwong): This should check that we create a valid path name. 64 NOTREACHED();
49 CHECK(IsStringASCII(partition_id)); 65 return FilePath();
50 return FilePath(kStoragePartitionDirname)
51 .Append(kExtensionsDirname)
52 .AppendASCII(partition_id)
53 .Append(kDefaultPartitionDirname);
54 } 66 }
55 67
56 StoragePartitionImpl::StoragePartitionImpl( 68 StoragePartitionImpl::StoragePartitionImpl(
57 const FilePath& partition_path, 69 const FilePath& partition_path,
58 quota::QuotaManager* quota_manager, 70 quota::QuotaManager* quota_manager,
59 ChromeAppCacheService* appcache_service, 71 ChromeAppCacheService* appcache_service,
60 fileapi::FileSystemContext* filesystem_context, 72 fileapi::FileSystemContext* filesystem_context,
61 webkit_database::DatabaseTracker* database_tracker, 73 webkit_database::DatabaseTracker* database_tracker,
62 DOMStorageContextImpl* dom_storage_context, 74 DOMStorageContextImpl* dom_storage_context,
63 IndexedDBContextImpl* indexed_db_context) 75 IndexedDBContextImpl* indexed_db_context)
(...skipping 17 matching lines...) Expand all
81 } 93 }
82 94
83 if (GetDOMStorageContext()) 95 if (GetDOMStorageContext())
84 GetDOMStorageContext()->Shutdown(); 96 GetDOMStorageContext()->Shutdown();
85 } 97 }
86 98
87 // TODO(ajwong): Break the direct dependency on |context|. We only 99 // TODO(ajwong): Break the direct dependency on |context|. We only
88 // need 3 pieces of info from it. 100 // need 3 pieces of info from it.
89 StoragePartitionImpl* StoragePartitionImpl::Create( 101 StoragePartitionImpl* StoragePartitionImpl::Create(
90 BrowserContext* context, 102 BrowserContext* context,
91 const std::string& partition_id, 103 const StoragePartitionDescriptor& partition_descriptor,
92 const FilePath& profile_path) { 104 const FilePath& profile_path) {
93 // Ensure that these methods are called on the UI thread, except for 105 // Ensure that these methods are called on the UI thread, except for
94 // unittests where a UI thread might not have been created. 106 // unittests where a UI thread might not have been created.
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
96 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); 108 !BrowserThread::IsMessageLoopValid(BrowserThread::UI));
97 109
98 FilePath partition_path = 110 FilePath partition_path =
99 profile_path.Append(GetPartitionPath(partition_id)); 111 profile_path.Append(GetStoragePartitionPath(partition_descriptor));
100 112
101 // All of the clients have to be created and registered with the 113 // All of the clients have to be created and registered with the
102 // QuotaManager prior to the QuotaManger being used. We do them 114 // QuotaManager prior to the QuotaManger being used. We do them
103 // all together here prior to handing out a reference to anything 115 // all together here prior to handing out a reference to anything
104 // that utilizes the QuotaManager. 116 // that utilizes the QuotaManager.
105 scoped_refptr<quota::QuotaManager> quota_manager = 117 scoped_refptr<quota::QuotaManager> quota_manager =
106 new quota::QuotaManager( 118 new quota::QuotaManager(
107 context->IsOffTheRecord(), partition_path, 119 partition_descriptor.in_memory, partition_path,
108 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), 120 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
109 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), 121 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
110 context->GetSpecialStoragePolicy()); 122 context->GetSpecialStoragePolicy());
111 123
112 // Each consumer is responsible for registering its QuotaClient during 124 // Each consumer is responsible for registering its QuotaClient during
113 // its construction. 125 // its construction.
114 scoped_refptr<fileapi::FileSystemContext> filesystem_context = 126 scoped_refptr<fileapi::FileSystemContext> filesystem_context =
115 CreateFileSystemContext(partition_path, context->IsOffTheRecord(), 127 CreateFileSystemContext(partition_path, partition_descriptor.in_memory,
116 context->GetSpecialStoragePolicy(), 128 context->GetSpecialStoragePolicy(),
117 quota_manager->proxy()); 129 quota_manager->proxy());
118 130
119 scoped_refptr<webkit_database::DatabaseTracker> database_tracker = 131 scoped_refptr<webkit_database::DatabaseTracker> database_tracker =
120 new webkit_database::DatabaseTracker( 132 new webkit_database::DatabaseTracker(
121 partition_path, context->IsOffTheRecord(), 133 partition_path, partition_descriptor.in_memory,
122 context->GetSpecialStoragePolicy(), quota_manager->proxy(), 134 context->GetSpecialStoragePolicy(), quota_manager->proxy(),
123 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); 135 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
124 136
125 FilePath path = context->IsOffTheRecord() ? FilePath() : partition_path; 137 FilePath path = partition_descriptor.in_memory ? FilePath() : partition_path;
126 scoped_refptr<DOMStorageContextImpl> dom_storage_context = 138 scoped_refptr<DOMStorageContextImpl> dom_storage_context =
127 new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy()); 139 new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy());
128 140
129 scoped_refptr<IndexedDBContextImpl> indexed_db_context = 141 scoped_refptr<IndexedDBContextImpl> indexed_db_context =
130 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(), 142 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(),
131 quota_manager->proxy(), 143 quota_manager->proxy(),
132 BrowserThread::GetMessageLoopProxyForThread( 144 BrowserThread::GetMessageLoopProxyForThread(
133 BrowserThread::WEBKIT_DEPRECATED)); 145 BrowserThread::WEBKIT_DEPRECATED));
134 146
135 scoped_refptr<ChromeAppCacheService> appcache_service = 147 scoped_refptr<ChromeAppCacheService> appcache_service =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 net::URLRequestContextGetter* url_request_context) { 197 net::URLRequestContextGetter* url_request_context) {
186 url_request_context_ = url_request_context; 198 url_request_context_ = url_request_context;
187 } 199 }
188 200
189 void StoragePartitionImpl::SetMediaURLRequestContext( 201 void StoragePartitionImpl::SetMediaURLRequestContext(
190 net::URLRequestContextGetter* media_url_request_context) { 202 net::URLRequestContextGetter* media_url_request_context) {
191 media_url_request_context_ = media_url_request_context; 203 media_url_request_context_ = media_url_request_context;
192 } 204 }
193 205
194 } // namespace content 206 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698