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/public/browser/browser_context.h" | 5 #include "content/public/browser/browser_context.h" |
6 | 6 |
7 #include "content/browser/appcache/chrome_appcache_service.h" | 7 #include "content/browser/appcache/chrome_appcache_service.h" |
8 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 8 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
9 #include "content/browser/download/download_file_manager.h" | 9 #include "content/browser/download/download_file_manager.h" |
10 #include "content/browser/download/download_manager_impl.h" | 10 #include "content/browser/download/download_manager_impl.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 static const char* kDownloadManagerKeyName = "download_manager"; | 37 static const char* kDownloadManagerKeyName = "download_manager"; |
38 static const char* kFileSystemContextKeyName = "content_file_system_context"; | 38 static const char* kFileSystemContextKeyName = "content_file_system_context"; |
39 static const char* kIndexedDBContextKeyName = "content_indexed_db_context"; | 39 static const char* kIndexedDBContextKeyName = "content_indexed_db_context"; |
40 static const char* kQuotaManagerKeyName = "content_quota_manager"; | 40 static const char* kQuotaManagerKeyName = "content_quota_manager"; |
41 | 41 |
42 namespace content { | 42 namespace content { |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 void CreateQuotaManagerAndClients(BrowserContext* context) { | 46 void CreateQuotaManagerAndClients(BrowserContext* context) { |
| 47 // Ensure that these methods are called on the UI thread, except for unittests |
| 48 // where a UI thread might not have been created. |
| 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 50 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); |
47 if (context->GetUserData(kQuotaManagerKeyName)) { | 51 if (context->GetUserData(kQuotaManagerKeyName)) { |
48 DCHECK(context->GetUserData(kDatabaseTrackerKeyName)); | 52 DCHECK(context->GetUserData(kDatabaseTrackerKeyName)); |
49 DCHECK(context->GetUserData(kDOMStorageContextKeyName)); | 53 DCHECK(context->GetUserData(kDOMStorageContextKeyName)); |
50 DCHECK(context->GetUserData(kFileSystemContextKeyName)); | 54 DCHECK(context->GetUserData(kFileSystemContextKeyName)); |
51 DCHECK(context->GetUserData(kIndexedDBContextKeyName)); | 55 DCHECK(context->GetUserData(kIndexedDBContextKeyName)); |
52 return; | 56 return; |
53 } | 57 } |
54 | 58 |
55 // All of the clients have to be created and registered with the | 59 // All of the clients have to be created and registered with the |
56 // QuotaManager prior to the QuotaManger being used. So we do them | 60 // QuotaManager prior to the QuotaManger being used. So we do them |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 140 |
137 DOMStorageContextImpl* GetDOMStorageContextImpl(BrowserContext* context) { | 141 DOMStorageContextImpl* GetDOMStorageContextImpl(BrowserContext* context) { |
138 return static_cast<DOMStorageContextImpl*>( | 142 return static_cast<DOMStorageContextImpl*>( |
139 BrowserContext::GetDOMStorageContext(context)); | 143 BrowserContext::GetDOMStorageContext(context)); |
140 } | 144 } |
141 | 145 |
142 } // namespace | 146 } // namespace |
143 | 147 |
144 DownloadManager* BrowserContext::GetDownloadManager( | 148 DownloadManager* BrowserContext::GetDownloadManager( |
145 BrowserContext* context) { | 149 BrowserContext* context) { |
| 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
146 if (!context->GetUserData(kDownloadManagerKeyName)) { | 151 if (!context->GetUserData(kDownloadManagerKeyName)) { |
147 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 152 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
148 DCHECK(rdh); | 153 DCHECK(rdh); |
149 DownloadFileManager* file_manager = rdh->download_file_manager(); | 154 DownloadFileManager* file_manager = rdh->download_file_manager(); |
150 DCHECK(file_manager); | 155 DCHECK(file_manager); |
151 scoped_refptr<DownloadManager> download_manager = | 156 scoped_refptr<DownloadManager> download_manager = |
152 new DownloadManagerImpl( | 157 new DownloadManagerImpl( |
153 file_manager, | 158 file_manager, |
154 scoped_ptr<DownloadItemFactory>(), | 159 scoped_ptr<DownloadItemFactory>(), |
155 GetContentClient()->browser()->GetNetLog()); | 160 GetContentClient()->browser()->GetNetLog()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 262 } |
258 | 263 |
259 if (GetUserData(kDOMStorageContextKeyName)) | 264 if (GetUserData(kDOMStorageContextKeyName)) |
260 GetDOMStorageContextImpl(this)->Shutdown(); | 265 GetDOMStorageContextImpl(this)->Shutdown(); |
261 | 266 |
262 if (GetUserData(kDownloadManagerKeyName)) | 267 if (GetUserData(kDownloadManagerKeyName)) |
263 GetDownloadManager(this)->Shutdown(); | 268 GetDownloadManager(this)->Shutdown(); |
264 } | 269 } |
265 | 270 |
266 } // namespace content | 271 } // namespace content |
OLD | NEW |