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 #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 "net/url_request/url_request_context_getter.h" | 10 #include "net/url_request/url_request_context_getter.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 if (GetDOMStorageContext()) | 83 if (GetDOMStorageContext()) |
84 GetDOMStorageContext()->Shutdown(); | 84 GetDOMStorageContext()->Shutdown(); |
85 } | 85 } |
86 | 86 |
87 // TODO(ajwong): Break the direct dependency on |context|. We only | 87 // TODO(ajwong): Break the direct dependency on |context|. We only |
88 // need 3 pieces of info from it. | 88 // need 3 pieces of info from it. |
89 StoragePartitionImpl* StoragePartitionImpl::Create( | 89 StoragePartitionImpl* StoragePartitionImpl::Create( |
90 BrowserContext* context, | 90 BrowserContext* context, |
91 const std::string& partition_id, | 91 const std::string& partition_id, |
92 const FilePath& profile_path) { | 92 const FilePath& profile_path, |
| 93 bool in_memory) { |
93 // Ensure that these methods are called on the UI thread, except for | 94 // Ensure that these methods are called on the UI thread, except for |
94 // unittests where a UI thread might not have been created. | 95 // unittests where a UI thread might not have been created. |
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
96 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); | 97 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); |
97 | 98 |
98 FilePath partition_path = | 99 FilePath partition_path = |
99 profile_path.Append(GetPartitionPath(partition_id)); | 100 profile_path.Append(GetPartitionPath(partition_id)); |
100 | 101 |
101 // All of the clients have to be created and registered with the | 102 // All of the clients have to be created and registered with the |
102 // QuotaManager prior to the QuotaManger being used. We do them | 103 // QuotaManager prior to the QuotaManger being used. We do them |
103 // all together here prior to handing out a reference to anything | 104 // all together here prior to handing out a reference to anything |
104 // that utilizes the QuotaManager. | 105 // that utilizes the QuotaManager. |
105 scoped_refptr<quota::QuotaManager> quota_manager = | 106 scoped_refptr<quota::QuotaManager> quota_manager = |
106 new quota::QuotaManager( | 107 new quota::QuotaManager( |
107 context->IsOffTheRecord(), partition_path, | 108 in_memory, partition_path, |
108 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 109 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
109 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), | 110 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
110 context->GetSpecialStoragePolicy()); | 111 context->GetSpecialStoragePolicy()); |
111 | 112 |
112 // Each consumer is responsible for registering its QuotaClient during | 113 // Each consumer is responsible for registering its QuotaClient during |
113 // its construction. | 114 // its construction. |
114 scoped_refptr<fileapi::FileSystemContext> filesystem_context = | 115 scoped_refptr<fileapi::FileSystemContext> filesystem_context = |
115 CreateFileSystemContext(partition_path, context->IsOffTheRecord(), | 116 CreateFileSystemContext(partition_path, in_memory, |
116 context->GetSpecialStoragePolicy(), | 117 context->GetSpecialStoragePolicy(), |
117 quota_manager->proxy()); | 118 quota_manager->proxy()); |
118 | 119 |
119 scoped_refptr<webkit_database::DatabaseTracker> database_tracker = | 120 scoped_refptr<webkit_database::DatabaseTracker> database_tracker = |
120 new webkit_database::DatabaseTracker( | 121 new webkit_database::DatabaseTracker( |
121 partition_path, context->IsOffTheRecord(), | 122 partition_path, in_memory, |
122 context->GetSpecialStoragePolicy(), quota_manager->proxy(), | 123 context->GetSpecialStoragePolicy(), quota_manager->proxy(), |
123 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 124 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
124 | 125 |
125 FilePath path = context->IsOffTheRecord() ? FilePath() : partition_path; | 126 FilePath path = in_memory ? FilePath() : partition_path; |
126 scoped_refptr<DOMStorageContextImpl> dom_storage_context = | 127 scoped_refptr<DOMStorageContextImpl> dom_storage_context = |
127 new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy()); | 128 new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy()); |
128 | 129 |
129 scoped_refptr<IndexedDBContextImpl> indexed_db_context = | 130 scoped_refptr<IndexedDBContextImpl> indexed_db_context = |
130 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(), | 131 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(), |
131 quota_manager->proxy(), | 132 quota_manager->proxy(), |
132 BrowserThread::GetMessageLoopProxyForThread( | 133 BrowserThread::GetMessageLoopProxyForThread( |
133 BrowserThread::WEBKIT_DEPRECATED)); | 134 BrowserThread::WEBKIT_DEPRECATED)); |
134 | 135 |
135 scoped_refptr<ChromeAppCacheService> appcache_service = | 136 scoped_refptr<ChromeAppCacheService> appcache_service = |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 net::URLRequestContextGetter* url_request_context) { | 186 net::URLRequestContextGetter* url_request_context) { |
186 url_request_context_ = url_request_context; | 187 url_request_context_ = url_request_context; |
187 } | 188 } |
188 | 189 |
189 void StoragePartitionImpl::SetMediaURLRequestContext( | 190 void StoragePartitionImpl::SetMediaURLRequestContext( |
190 net::URLRequestContextGetter* media_url_request_context) { | 191 net::URLRequestContextGetter* media_url_request_context) { |
191 media_url_request_context_ = media_url_request_context; | 192 media_url_request_context_ = media_url_request_context; |
192 } | 193 } |
193 | 194 |
194 } // namespace content | 195 } // namespace content |
OLD | NEW |