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/appcache/chrome_appcache_service.h" | 5 #include "content/browser/appcache/chrome_appcache_service.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "content/public/browser/content_browser_client.h" | 9 #include "content/public/browser/content_browser_client.h" |
10 #include "content/public/browser/resource_context.h" | 10 #include "content/public/browser/resource_context.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/url_request/url_request_context_getter.h" | |
13 #include "webkit/appcache/appcache_storage_impl.h" | |
12 #include "webkit/quota/quota_manager.h" | 14 #include "webkit/quota/quota_manager.h" |
13 | 15 |
14 using content::BrowserThread; | 16 using content::BrowserThread; |
15 | 17 |
16 ChromeAppCacheService::ChromeAppCacheService( | 18 ChromeAppCacheService::ChromeAppCacheService( |
17 quota::QuotaManagerProxy* quota_manager_proxy) | 19 quota::QuotaManagerProxy* quota_manager_proxy) |
18 : AppCacheService(quota_manager_proxy), | 20 : AppCacheService(quota_manager_proxy), |
19 resource_context_(NULL) { | 21 resource_context_(NULL) { |
20 } | 22 } |
21 | 23 |
22 void ChromeAppCacheService::InitializeOnIOThread( | 24 void ChromeAppCacheService::InitializeOnIOThread( |
23 const FilePath& cache_path, | 25 const FilePath& cache_path, |
24 content::ResourceContext* resource_context, | 26 content::ResourceContext* resource_context, |
27 net::URLRequestContextGetter* request_context_getter, | |
25 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { | 28 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { |
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
27 | 30 |
28 cache_path_ = cache_path; | 31 cache_path_ = cache_path; |
29 resource_context_ = resource_context; | 32 resource_context_ = resource_context; |
30 set_request_context(resource_context->GetRequestContext()); | 33 |
34 // The |request_context_getter| can be NULL in some unit tests. | |
awong
2012/09/15 00:33:29
Can you file a bug against me and add a TODO to re
michaeln
2012/09/15 01:50:56
Done.
| |
35 if (request_context_getter) | |
36 set_request_context(request_context_getter->GetURLRequestContext()); | |
31 | 37 |
32 // Init our base class. | 38 // Init our base class. |
33 Initialize( | 39 Initialize( |
34 cache_path_, | 40 cache_path_, |
35 BrowserThread::GetMessageLoopProxyForThread( | 41 BrowserThread::GetMessageLoopProxyForThread( |
36 BrowserThread::FILE_USER_BLOCKING), | 42 BrowserThread::FILE_USER_BLOCKING), |
37 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | 43 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
38 set_appcache_policy(this); | 44 set_appcache_policy(this); |
39 set_special_storage_policy(special_storage_policy); | 45 set_special_storage_policy(special_storage_policy); |
40 } | 46 } |
(...skipping 16 matching lines...) Expand all Loading... | |
57 ChromeAppCacheService::~ChromeAppCacheService() {} | 63 ChromeAppCacheService::~ChromeAppCacheService() {} |
58 | 64 |
59 void ChromeAppCacheService::DeleteOnCorrectThread() const { | 65 void ChromeAppCacheService::DeleteOnCorrectThread() const { |
60 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && | 66 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && |
61 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 67 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
62 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 68 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
63 return; | 69 return; |
64 } | 70 } |
65 delete this; | 71 delete this; |
66 } | 72 } |
OLD | NEW |