| 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/file_system/browser_file_system_helper.h" | 8 #include "content/browser/file_system/browser_file_system_helper.h" |
| 9 #include "content/browser/in_process_webkit/webkit_context.h" | 9 #include "content/browser/in_process_webkit/webkit_context.h" |
| 10 #include "content/browser/resource_context_impl.h" | 10 #include "content/browser/resource_context_impl.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 BrowserThread::WEBKIT_DEPRECATED)); | 72 BrowserThread::WEBKIT_DEPRECATED)); |
| 73 context->SetUserData(kWebKitContextKeyName, | 73 context->SetUserData(kWebKitContextKeyName, |
| 74 new UserDataAdapter<WebKitContext>(webkit_context)); | 74 new UserDataAdapter<WebKitContext>(webkit_context)); |
| 75 | 75 |
| 76 scoped_refptr<ChromeAppCacheService> appcache_service = | 76 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 77 new ChromeAppCacheService(quota_manager->proxy()); | 77 new ChromeAppCacheService(quota_manager->proxy()); |
| 78 context->SetUserData( | 78 context->SetUserData( |
| 79 kAppCacheServicKeyName, | 79 kAppCacheServicKeyName, |
| 80 new UserDataAdapter<ChromeAppCacheService>(appcache_service)); | 80 new UserDataAdapter<ChromeAppCacheService>(appcache_service)); |
| 81 | 81 |
| 82 InitializeResourceContext(context); | 82 EnsureResourceContextInitialized(context); |
| 83 | 83 |
| 84 // Check first to avoid memory leak in unittests. | 84 // Check first to avoid memory leak in unittests. |
| 85 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 85 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
| 86 BrowserThread::PostTask( | 86 BrowserThread::PostTask( |
| 87 BrowserThread::IO, FROM_HERE, | 87 BrowserThread::IO, FROM_HERE, |
| 88 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, | 88 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, |
| 89 appcache_service, | 89 appcache_service, |
| 90 context->IsOffTheRecord() ? FilePath() : | 90 context->IsOffTheRecord() ? FilePath() : |
| 91 context->GetPath().Append(content::kAppCacheDirname), | 91 context->GetPath().Append(content::kAppCacheDirname), |
| 92 context->GetResourceContext(), | 92 context->GetResourceContext(), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 FileSystemContext* BrowserContext::GetFileSystemContext( | 120 FileSystemContext* BrowserContext::GetFileSystemContext( |
| 121 BrowserContext* browser_context) { | 121 BrowserContext* browser_context) { |
| 122 CreateQuotaManagerAndClients(browser_context); | 122 CreateQuotaManagerAndClients(browser_context); |
| 123 return UserDataAdapter<FileSystemContext>::Get( | 123 return UserDataAdapter<FileSystemContext>::Get( |
| 124 browser_context, kFileSystemContextKeyName); | 124 browser_context, kFileSystemContextKeyName); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) { | 127 void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) { |
| 128 if (context->GetResourceContext()->GetUserData(kWebKitContextKeyName)) | 128 content::EnsureResourceContextInitialized(context); |
| 129 return; | |
| 130 InitializeResourceContext(context); | |
| 131 } | 129 } |
| 132 | 130 |
| 133 BrowserContext::~BrowserContext() { | 131 BrowserContext::~BrowserContext() { |
| 134 if (GetUserData(kDatabaseTrackerKeyName) && | 132 if (GetUserData(kDatabaseTrackerKeyName) && |
| 135 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 133 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
| 136 BrowserThread::PostTask( | 134 BrowserThread::PostTask( |
| 137 BrowserThread::FILE, FROM_HERE, | 135 BrowserThread::FILE, FROM_HERE, |
| 138 base::Bind(&webkit_database::DatabaseTracker::Shutdown, | 136 base::Bind(&webkit_database::DatabaseTracker::Shutdown, |
| 139 GetDatabaseTracker(this))); | 137 GetDatabaseTracker(this))); |
| 140 } | 138 } |
| 141 } | 139 } |
| 142 | 140 |
| 143 } // namespace content | 141 } // namespace content |
| OLD | NEW |