OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ | |
7 | |
8 #include "base/file_path.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/sequenced_task_runner_helpers.h" | |
11 #include "base/string16.h" | |
12 #include "content/public/browser/browser_thread.h" | |
13 #include "googleurl/src/gurl.h" | |
14 | |
15 namespace content { | |
16 class DOMStorageContext; | |
17 class IndexedDBContext; | |
18 class ResourceContext; | |
19 } | |
20 | |
21 namespace fileapi { | |
22 class FileSystemContext; | |
23 } | |
24 | |
25 namespace net { | |
26 class URLRequestContextGetter; | |
27 } | |
28 | |
29 namespace webkit_database { | |
30 class DatabaseTracker; | |
31 } | |
32 | |
33 class Profile; | |
34 | |
35 // A helper class that takes care of removing local storage, databases and | |
36 // cookies for a given extension. This is used by | |
37 // ExtensionService::ClearExtensionData() upon uninstalling an extension. | |
38 class ExtensionDataDeleter | |
39 : public base::RefCountedThreadSafe< | |
40 ExtensionDataDeleter, content::BrowserThread::DeleteOnUIThread> { | |
41 public: | |
42 // Starts removing data. The extension should not be running when this is | |
43 // called. Cookies are deleted on the current thread, local storage and | |
44 // databases/settings are deleted asynchronously on the webkit and file | |
45 // threads, respectively. This function must be called from the UI thread. | |
46 static void StartDeleting( | |
47 Profile* profile, | |
48 const std::string& extension_id, | |
49 const GURL& storage_origin, | |
50 bool is_storage_isolated); | |
51 | |
52 private: | |
53 friend struct content::BrowserThread::DeleteOnThread< | |
54 content::BrowserThread::UI>; | |
55 friend class base::DeleteHelper<ExtensionDataDeleter>; | |
56 | |
57 ExtensionDataDeleter( | |
58 Profile* profile, | |
59 const std::string& extension_id, | |
60 const GURL& storage_origin, | |
61 bool is_storage_isolated); | |
62 ~ExtensionDataDeleter(); | |
63 | |
64 // Deletes the cookies for the extension. May only be called on the io | |
65 // thread. | |
66 void DeleteCookiesOnIOThread(); | |
67 | |
68 // Deletes the database for the extension. May only be called on the file | |
69 // thread. | |
70 void DeleteDatabaseOnFileThread(); | |
71 | |
72 // Deletes indexed db files for the extension. May only be called on the | |
73 // webkit thread. | |
74 void DeleteIndexedDBOnWebkitThread( | |
75 scoped_refptr<content::IndexedDBContext> indexed_db_context); | |
76 | |
77 // Deletes filesystem files for the extension. May only be called on the | |
78 // file thread. | |
79 void DeleteFileSystemOnFileThread(); | |
80 | |
81 // Deletes appcache files for the extension. May only be called on the IO | |
82 // thread. | |
83 void DeleteAppcachesOnIOThread(content::ResourceContext* resource_context); | |
84 | |
85 // The ID of the extension being deleted. | |
86 const std::string extension_id_; | |
87 | |
88 // The database context for deleting the database. | |
89 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | |
90 | |
91 // Provides access to the request context. | |
92 scoped_refptr<net::URLRequestContextGetter> extension_request_context_; | |
93 | |
94 // The origin of the extension/app for which we're going to clear data. | |
95 GURL storage_origin_; | |
96 | |
97 // The security origin identifier for which we're deleting stuff. | |
98 string16 origin_id_; | |
99 | |
100 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | |
101 | |
102 // If non-empty, the extension we're deleting is an isolated app, and this | |
103 // is its directory which we should delete. | |
104 FilePath isolated_app_path_; | |
105 | |
106 DISALLOW_COPY_AND_ASSIGN(ExtensionDataDeleter); | |
107 }; | |
108 | |
109 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ | |
OLD | NEW |