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

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

Issue 10600009: Support partitioning of storage contexts based on render_id. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Forgot a funciton. Created 8 years, 5 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/storage_partition.h"
6
7 #include "content/browser/appcache/chrome_appcache_service.h"
8 #include "content/browser/dom_storage/dom_storage_context_impl.h"
9 #include "content/browser/fileapi/browser_file_system_helper.h"
10 #include "content/browser/in_process_webkit/indexed_db_context_impl.h"
11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "webkit/database/database_tracker.h"
14 #include "webkit/quota/quota_manager.h"
15
16 using content::BrowserThread;
17
18 StoragePartition::StoragePartition(
19 const FilePath& partition_path,
20 quota::QuotaManager* quota_manager,
21 ChromeAppCacheService* appcache_service,
22 fileapi::FileSystemContext* filesystem_context,
23 webkit_database::DatabaseTracker* database_tracker,
24 DOMStorageContextImpl* dom_storage_context,
25 content::IndexedDBContext* indexed_db_context)
26 : partition_path_(partition_path),
27 quota_manager_(quota_manager),
28 appcache_service_(appcache_service),
29 filesystem_context_(filesystem_context),
30 database_tracker_(database_tracker),
31 dom_storage_context_(dom_storage_context),
32 indexed_db_context_(indexed_db_context) {
33 }
34
35 StoragePartition::~StoragePartition() {
36 // These message loop checks are just to avoid leaks in unittests.
37 if (database_tracker() &&
38 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
39 BrowserThread::PostTask(
40 BrowserThread::FILE, FROM_HERE,
41 base::Bind(&webkit_database::DatabaseTracker::Shutdown,
42 database_tracker()));
43 }
44
45 if (dom_storage_context())
46 dom_storage_context()->Shutdown();
47 }
48
49 // TODO(ajwong): Break the direct dependency on |context|. We only
50 // need 3 pieces of info from it.
51 StoragePartition* StoragePartition::Create(content::BrowserContext* context,
52 const FilePath& partition_path) {
53 // Ensure that these methods are called on the UI thread, except for
54 // unittests where a UI thread might not have been created.
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
56 !BrowserThread::IsMessageLoopValid(BrowserThread::UI));
57
58 // All of the clients have to be created and registered with the
59 // QuotaManager prior to the QuotaManger being used. We do them
60 // all together here prior to handing out a reference to anything
61 // that utilizes the QuotaManager.
62 scoped_refptr<quota::QuotaManager> quota_manager =
63 new quota::QuotaManager(
64 context->IsOffTheRecord(), partition_path,
65 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
66 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
67 context->GetSpecialStoragePolicy());
68
69 // Each consumer is responsible for registering its QuotaClient during
70 // its construction.
71 scoped_refptr<fileapi::FileSystemContext> filesystem_context =
72 CreateFileSystemContext(partition_path, context->IsOffTheRecord(),
73 context->GetSpecialStoragePolicy(),
74 quota_manager->proxy());
75
76 scoped_refptr<webkit_database::DatabaseTracker> database_tracker =
77 new webkit_database::DatabaseTracker(
78 partition_path, context->IsOffTheRecord(),
79 context->GetSpecialStoragePolicy(), quota_manager->proxy(),
80 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
81
82 FilePath path = context->IsOffTheRecord() ? FilePath() : partition_path;
83 scoped_refptr<DOMStorageContextImpl> dom_storage_context =
84 new DOMStorageContextImpl(path, context->GetSpecialStoragePolicy());
85
86 scoped_refptr<IndexedDBContextImpl> indexed_db_context =
87 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(),
88 quota_manager->proxy(),
89 BrowserThread::GetMessageLoopProxyForThread(
90 BrowserThread::WEBKIT_DEPRECATED));
91
92 scoped_refptr<ChromeAppCacheService> appcache_service =
93 new ChromeAppCacheService(quota_manager->proxy());
94
95 return new StoragePartition(partition_path,
96 quota_manager,
97 appcache_service,
98 filesystem_context,
99 database_tracker,
100 dom_storage_context,
101 indexed_db_context);
102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698