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 "chrome/browser/extensions/data_deleter.h" | 5 #include "chrome/browser/extensions/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/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/settings/settings_frontend.h" | 10 #include "chrome/browser/extensions/settings/settings_frontend.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.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/public/browser/dom_storage_context.h" | 15 #include "content/public/browser/dom_storage_context.h" |
16 #include "content/public/browser/indexed_db_context.h" | 16 #include "content/public/browser/indexed_db_context.h" |
17 #include "content/public/browser/resource_context.h" | |
18 #include "content/public/browser/storage_partition.h" | 17 #include "content/public/browser/storage_partition.h" |
19 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
20 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
21 #include "net/cookies/cookie_monster.h" | 20 #include "net/cookies/cookie_monster.h" |
22 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
23 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
24 #include "webkit/appcache/appcache_service.h" | 23 #include "webkit/appcache/appcache_service.h" |
25 #include "webkit/database/database_tracker.h" | 24 #include "webkit/database/database_tracker.h" |
26 #include "webkit/database/database_util.h" | 25 #include "webkit/database/database_util.h" |
27 #include "webkit/fileapi/file_system_context.h" | 26 #include "webkit/fileapi/file_system_context.h" |
28 | 27 |
29 using content::BrowserContext; | 28 using content::BrowserContext; |
30 using content::BrowserThread; | 29 using content::BrowserThread; |
31 using content::DOMStorageContext; | 30 using content::DOMStorageContext; |
32 using content::IndexedDBContext; | 31 using content::IndexedDBContext; |
33 using content::ResourceContext; | |
34 | 32 |
35 namespace extensions { | 33 namespace extensions { |
36 | 34 |
37 // static | 35 // static |
38 void DataDeleter::StartDeleting(Profile* profile, | 36 void DataDeleter::StartDeleting(Profile* profile, |
39 const std::string& extension_id, | 37 const std::string& extension_id, |
40 const GURL& storage_origin, | 38 const GURL& storage_origin, |
41 bool is_storage_isolated) { | 39 bool is_storage_isolated) { |
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
43 DCHECK(profile); | 41 DCHECK(profile); |
(...skipping 19 matching lines...) Expand all Loading... |
63 base::Bind(&DataDeleter::DeleteDatabaseOnFileThread, deleter)); | 61 base::Bind(&DataDeleter::DeleteDatabaseOnFileThread, deleter)); |
64 | 62 |
65 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
66 BrowserThread::FILE, FROM_HERE, | 64 BrowserThread::FILE, FROM_HERE, |
67 base::Bind(&DataDeleter::DeleteFileSystemOnFileThread, deleter)); | 65 base::Bind(&DataDeleter::DeleteFileSystemOnFileThread, deleter)); |
68 | 66 |
69 BrowserThread::PostTask( | 67 BrowserThread::PostTask( |
70 BrowserThread::IO, FROM_HERE, | 68 BrowserThread::IO, FROM_HERE, |
71 base::Bind(&DataDeleter::DeleteAppcachesOnIOThread, | 69 base::Bind(&DataDeleter::DeleteAppcachesOnIOThread, |
72 deleter, | 70 deleter, |
73 profile->GetResourceContext())); | 71 BrowserContext::GetDefaultStoragePartition(profile)-> |
| 72 GetAppCacheService())); |
74 | 73 |
75 profile->GetExtensionService()->settings_frontend()-> | 74 profile->GetExtensionService()->settings_frontend()-> |
76 DeleteStorageSoon(extension_id); | 75 DeleteStorageSoon(extension_id); |
77 } | 76 } |
78 | 77 |
79 DataDeleter::DataDeleter( | 78 DataDeleter::DataDeleter( |
80 Profile* profile, | 79 Profile* profile, |
81 const std::string& extension_id, | 80 const std::string& extension_id, |
82 const GURL& storage_origin, | 81 const GURL& storage_origin, |
83 bool is_storage_isolated) | 82 bool is_storage_isolated) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
132 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_); | 131 file_system_context_->DeleteDataForOriginOnFileThread(storage_origin_); |
133 | 132 |
134 // TODO(creis): The following call fails because the request context is still | 133 // TODO(creis): The following call fails because the request context is still |
135 // around, and holding open file handles in this directory. | 134 // around, and holding open file handles in this directory. |
136 // See http://crbug.com/85127 | 135 // See http://crbug.com/85127 |
137 if (!isolated_app_path_.empty()) | 136 if (!isolated_app_path_.empty()) |
138 file_util::Delete(isolated_app_path_, true); | 137 file_util::Delete(isolated_app_path_, true); |
139 } | 138 } |
140 | 139 |
141 void DataDeleter::DeleteAppcachesOnIOThread(ResourceContext* context) { | 140 void DataDeleter::DeleteAppcachesOnIOThread( |
| 141 appcache::AppCacheService* appcache_service) { |
142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
143 ResourceContext::GetAppCacheService(context)->DeleteAppCachesForOrigin( | 143 appcache_service->DeleteAppCachesForOrigin(storage_origin_, |
144 storage_origin_, net::CompletionCallback()); | 144 net::CompletionCallback()); |
145 } | 145 } |
146 | 146 |
147 } // namespace extensions | 147 } // namespace extensions |
OLD | NEW |