OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_data_deleter.h" | 5 #include "chrome/browser/extensions/extension_data_deleter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/settings/settings_frontend.h" | 11 #include "chrome/browser/extensions/settings/settings_frontend.h" |
12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "content/browser/appcache/chrome_appcache_service.h" | |
16 #include "content/browser/in_process_webkit/webkit_context.h" | 15 #include "content/browser/in_process_webkit/webkit_context.h" |
| 16 #include "content/public/browser/resource_context.h" |
17 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
18 #include "net/base/cookie_monster.h" | 18 #include "net/base/cookie_monster.h" |
19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
20 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
21 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 22 #include "webkit/appcache/appcache_service.h" |
22 #include "webkit/database/database_tracker.h" | 23 #include "webkit/database/database_tracker.h" |
23 #include "webkit/database/database_util.h" | 24 #include "webkit/database/database_util.h" |
24 #include "webkit/fileapi/file_system_context.h" | 25 #include "webkit/fileapi/file_system_context.h" |
25 | 26 |
26 using content::BrowserContext; | 27 using content::BrowserContext; |
27 using content::BrowserThread; | 28 using content::BrowserThread; |
| 29 using content::ResourceContext; |
28 | 30 |
29 // static | 31 // static |
30 void ExtensionDataDeleter::StartDeleting( | 32 void ExtensionDataDeleter::StartDeleting( |
31 Profile* profile, | 33 Profile* profile, |
32 const std::string& extension_id, | 34 const std::string& extension_id, |
33 const GURL& storage_origin, | 35 const GURL& storage_origin, |
34 bool is_storage_isolated) { | 36 bool is_storage_isolated) { |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
36 DCHECK(profile); | 38 DCHECK(profile); |
37 scoped_refptr<ExtensionDataDeleter> deleter = | 39 scoped_refptr<ExtensionDataDeleter> deleter = |
(...skipping 21 matching lines...) Expand all Loading... |
59 &ExtensionDataDeleter::DeleteDatabaseOnFileThread, deleter)); | 61 &ExtensionDataDeleter::DeleteDatabaseOnFileThread, deleter)); |
60 | 62 |
61 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
62 BrowserThread::FILE, FROM_HERE, | 64 BrowserThread::FILE, FROM_HERE, |
63 base::Bind( | 65 base::Bind( |
64 &ExtensionDataDeleter::DeleteFileSystemOnFileThread, deleter)); | 66 &ExtensionDataDeleter::DeleteFileSystemOnFileThread, deleter)); |
65 | 67 |
66 BrowserThread::PostTask( | 68 BrowserThread::PostTask( |
67 BrowserThread::IO, FROM_HERE, | 69 BrowserThread::IO, FROM_HERE, |
68 base::Bind( | 70 base::Bind( |
69 &ExtensionDataDeleter::DeleteAppcachesOnIOThread, deleter)); | 71 &ExtensionDataDeleter::DeleteAppcachesOnIOThread, deleter, |
| 72 profile->GetResourceContext())); |
70 | 73 |
71 profile->GetExtensionService()->settings_frontend()-> | 74 profile->GetExtensionService()->settings_frontend()-> |
72 DeleteStorageSoon(extension_id); | 75 DeleteStorageSoon(extension_id); |
73 } | 76 } |
74 | 77 |
75 ExtensionDataDeleter::ExtensionDataDeleter( | 78 ExtensionDataDeleter::ExtensionDataDeleter( |
76 Profile* profile, | 79 Profile* profile, |
77 const std::string& extension_id, | 80 const std::string& extension_id, |
78 const GURL& storage_origin, | 81 const GURL& storage_origin, |
79 bool is_storage_isolated) | 82 bool is_storage_isolated) |
80 : extension_id_(extension_id) { | 83 : extension_id_(extension_id) { |
81 appcache_service_ = BrowserContext::GetAppCacheService(profile); | |
82 webkit_context_ = BrowserContext::GetWebKitContext(profile); | 84 webkit_context_ = BrowserContext::GetWebKitContext(profile); |
83 database_tracker_ = BrowserContext::GetDatabaseTracker(profile); | 85 database_tracker_ = BrowserContext::GetDatabaseTracker(profile); |
84 // Pick the right request context depending on whether it's an extension, | 86 // Pick the right request context depending on whether it's an extension, |
85 // isolated app, or regular app. | 87 // isolated app, or regular app. |
86 if (storage_origin.SchemeIs(chrome::kExtensionScheme)) { | 88 if (storage_origin.SchemeIs(chrome::kExtensionScheme)) { |
87 extension_request_context_ = profile->GetRequestContextForExtensions(); | 89 extension_request_context_ = profile->GetRequestContextForExtensions(); |
88 } else if (is_storage_isolated) { | 90 } else if (is_storage_isolated) { |
89 extension_request_context_ = | 91 extension_request_context_ = |
90 profile->GetRequestContextForIsolatedApp(extension_id); | 92 profile->GetRequestContextForIsolatedApp(extension_id); |
91 isolated_app_path_ = profile->GetPath(). | 93 isolated_app_path_ = profile->GetPath(). |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
136 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_); | 138 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_); |
137 | 139 |
138 // TODO(creis): The following call fails because the request context is still | 140 // TODO(creis): The following call fails because the request context is still |
139 // around, and holding open file handles in this directory. | 141 // around, and holding open file handles in this directory. |
140 // See http://crbug.com/85127 | 142 // See http://crbug.com/85127 |
141 if (!isolated_app_path_.empty()) | 143 if (!isolated_app_path_.empty()) |
142 file_util::Delete(isolated_app_path_, true); | 144 file_util::Delete(isolated_app_path_, true); |
143 } | 145 } |
144 | 146 |
145 void ExtensionDataDeleter::DeleteAppcachesOnIOThread() { | 147 void ExtensionDataDeleter::DeleteAppcachesOnIOThread(ResourceContext* context) { |
146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
147 appcache_service_->DeleteAppCachesForOrigin( | 149 ResourceContext::GetAppCacheService(context)->DeleteAppCachesForOrigin( |
148 storage_origin_, net::CompletionCallback()); | 150 storage_origin_, net::CompletionCallback()); |
149 } | 151 } |
OLD | NEW |