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/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "content/browser/appcache/appcache_executable_handler_impl.h" |
8 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/content_browser_client.h" | 10 #include "content/public/browser/content_browser_client.h" |
10 #include "content/public/browser/resource_context.h" | 11 #include "content/public/browser/resource_context.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 #include "net/url_request/url_request_context_getter.h" | 13 #include "net/url_request/url_request_context_getter.h" |
13 #include "webkit/browser/appcache/appcache_storage_impl.h" | 14 #include "webkit/browser/appcache/appcache_storage_impl.h" |
14 #include "webkit/browser/quota/quota_manager.h" | 15 #include "webkit/browser/quota/quota_manager.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 ChromeAppCacheService::ChromeAppCacheService( | 19 ChromeAppCacheService::ChromeAppCacheService( |
19 quota::QuotaManagerProxy* quota_manager_proxy) | 20 quota::QuotaManagerProxy* quota_manager_proxy) |
20 : AppCacheService(quota_manager_proxy), | 21 : AppCacheService(quota_manager_proxy), |
21 resource_context_(NULL) { | 22 resource_context_(NULL) { |
22 } | 23 } |
23 | 24 |
24 void ChromeAppCacheService::InitializeOnIOThread( | 25 void ChromeAppCacheService::InitializeOnIOThread( |
25 const base::FilePath& cache_path, | 26 const base::FilePath& cache_path, |
26 ResourceContext* resource_context, | 27 ResourceContext* resource_context, |
27 net::URLRequestContextGetter* request_context_getter, | 28 net::URLRequestContextGetter* request_context_getter, |
28 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { | 29 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
| 30 const WorkerStoragePartition& worker_storage_partition, |
| 31 ChromeBlobStorageContext* blob_context) { |
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
30 | 33 |
31 cache_path_ = cache_path; | 34 cache_path_ = cache_path; |
32 resource_context_ = resource_context; | 35 resource_context_ = resource_context; |
| 36 executable_handler_factory_.reset(new AppCacheExecutableHandlerFactoryImpl( |
| 37 resource_context, worker_storage_partition, blob_context)); |
33 | 38 |
34 // The |request_context_getter| can be NULL in some unit tests. | 39 // The |request_context_getter| can be NULL in some unit tests. |
35 // | 40 // |
36 // TODO(ajwong): TestProfile is difficult to work with. The | 41 // TODO(ajwong): TestProfile is difficult to work with. The |
37 // SafeBrowsing tests require that GetRequestContext return NULL | 42 // SafeBrowsing tests require that GetRequestContext return NULL |
38 // so we can't depend on having a non-NULL value here. See crbug/149783. | 43 // so we can't depend on having a non-NULL value here. See crbug/149783. |
39 if (request_context_getter) | 44 if (request_context_getter) |
40 set_request_context(request_context_getter->GetURLRequestContext()); | 45 set_request_context(request_context_getter->GetURLRequestContext()); |
41 | 46 |
42 // Init our base class. | 47 // Init our base class. |
43 Initialize( | 48 Initialize( |
44 cache_path_, | 49 cache_path_, |
45 BrowserThread::GetMessageLoopProxyForThread( | 50 BrowserThread::GetMessageLoopProxyForThread( |
46 BrowserThread::FILE_USER_BLOCKING) | 51 BrowserThread::FILE_USER_BLOCKING) |
47 .get(), | 52 .get(), |
48 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE).get()); | 53 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE).get()); |
49 set_appcache_policy(this); | 54 set_appcache_policy(this); |
50 set_special_storage_policy(special_storage_policy.get()); | 55 set_special_storage_policy(special_storage_policy.get()); |
| 56 set_executable_handler_factory(executable_handler_factory_.get()); |
51 } | 57 } |
52 | 58 |
53 bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url, | 59 bool ChromeAppCacheService::CanLoadAppCache(const GURL& manifest_url, |
54 const GURL& first_party) { | 60 const GURL& first_party) { |
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
56 // We don't prompt for read access. | 62 // We don't prompt for read access. |
57 return GetContentClient()->browser()->AllowAppCache( | 63 return GetContentClient()->browser()->AllowAppCache( |
58 manifest_url, first_party, resource_context_); | 64 manifest_url, first_party, resource_context_); |
59 } | 65 } |
60 | 66 |
61 bool ChromeAppCacheService::CanCreateAppCache( | 67 bool ChromeAppCacheService::CanCreateAppCache( |
62 const GURL& manifest_url, const GURL& first_party) { | 68 const GURL& manifest_url, const GURL& first_party) { |
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
64 return GetContentClient()->browser()->AllowAppCache( | 70 return GetContentClient()->browser()->AllowAppCache( |
65 manifest_url, first_party, resource_context_); | 71 manifest_url, first_party, resource_context_); |
66 } | 72 } |
67 | 73 |
68 ChromeAppCacheService::~ChromeAppCacheService() {} | 74 ChromeAppCacheService::~ChromeAppCacheService() {} |
69 | 75 |
70 void ChromeAppCacheService::DeleteOnCorrectThread() const { | 76 void ChromeAppCacheService::DeleteOnCorrectThread() const { |
71 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && | 77 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && |
72 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 78 !BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
73 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 79 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
74 return; | 80 return; |
75 } | 81 } |
76 delete this; | 82 delete this; |
77 } | 83 } |
78 | 84 |
79 } // namespace content | 85 } // namespace content |
OLD | NEW |