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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_DATA_DELETER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_DATA_DELETER_H_ |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/sequenced_task_runner_helpers.h" | 10 #include "base/sequenced_task_runner_helpers.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class DOMStorageContext; | 16 class DOMStorageContext; |
17 class IndexedDBContext; | 17 class IndexedDBContext; |
18 class ResourceContext; | 18 class ResourceContext; |
19 } | 19 } |
20 | 20 |
21 namespace fileapi { | 21 namespace fileapi { |
22 class FileSystemContext; | 22 class FileSystemContext; |
23 } | 23 } |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
27 } | 27 } |
28 | 28 |
29 namespace webkit_database { | 29 namespace webkit_database { |
30 class DatabaseTracker; | 30 class DatabaseTracker; |
31 } | 31 } |
32 | 32 |
33 class Profile; | 33 class Profile; |
34 | 34 |
| 35 namespace extensions { |
| 36 |
35 // A helper class that takes care of removing local storage, databases and | 37 // A helper class that takes care of removing local storage, databases and |
36 // cookies for a given extension. This is used by | 38 // cookies for a given extension. This is used by |
37 // ExtensionService::ClearExtensionData() upon uninstalling an extension. | 39 // ExtensionService::ClearExtensionData() upon uninstalling an extension. |
38 class ExtensionDataDeleter | 40 class DataDeleter : public base::RefCountedThreadSafe< |
39 : public base::RefCountedThreadSafe< | 41 DataDeleter, content::BrowserThread::DeleteOnUIThread> { |
40 ExtensionDataDeleter, content::BrowserThread::DeleteOnUIThread> { | |
41 public: | 42 public: |
42 // Starts removing data. The extension should not be running when this is | 43 // 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 // called. Cookies are deleted on the current thread, local storage and |
44 // databases/settings are deleted asynchronously on the webkit and file | 45 // databases/settings are deleted asynchronously on the webkit and file |
45 // threads, respectively. This function must be called from the UI thread. | 46 // threads, respectively. This function must be called from the UI thread. |
46 static void StartDeleting( | 47 static void StartDeleting( |
47 Profile* profile, | 48 Profile* profile, |
48 const std::string& extension_id, | 49 const std::string& extension_id, |
49 const GURL& storage_origin, | 50 const GURL& storage_origin, |
50 bool is_storage_isolated); | 51 bool is_storage_isolated); |
51 | 52 |
52 private: | 53 private: |
53 friend struct content::BrowserThread::DeleteOnThread< | 54 friend struct content::BrowserThread::DeleteOnThread< |
54 content::BrowserThread::UI>; | 55 content::BrowserThread::UI>; |
55 friend class base::DeleteHelper<ExtensionDataDeleter>; | 56 friend class base::DeleteHelper<DataDeleter>; |
56 | 57 |
57 ExtensionDataDeleter( | 58 DataDeleter(Profile* profile, |
58 Profile* profile, | 59 const std::string& extension_id, |
59 const std::string& extension_id, | 60 const GURL& storage_origin, |
60 const GURL& storage_origin, | 61 bool is_storage_isolated); |
61 bool is_storage_isolated); | 62 ~DataDeleter(); |
62 ~ExtensionDataDeleter(); | |
63 | 63 |
64 // Deletes the cookies for the extension. May only be called on the io | 64 // Deletes the cookies for the extension. May only be called on the io |
65 // thread. | 65 // thread. |
66 void DeleteCookiesOnIOThread(); | 66 void DeleteCookiesOnIOThread(); |
67 | 67 |
68 // Deletes the database for the extension. May only be called on the file | 68 // Deletes the database for the extension. May only be called on the file |
69 // thread. | 69 // thread. |
70 void DeleteDatabaseOnFileThread(); | 70 void DeleteDatabaseOnFileThread(); |
71 | 71 |
72 // Deletes indexed db files for the extension. May only be called on the | 72 // Deletes indexed db files for the extension. May only be called on the |
(...skipping 23 matching lines...) Expand all Loading... |
96 | 96 |
97 // The security origin identifier for which we're deleting stuff. | 97 // The security origin identifier for which we're deleting stuff. |
98 string16 origin_id_; | 98 string16 origin_id_; |
99 | 99 |
100 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 100 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
101 | 101 |
102 // If non-empty, the extension we're deleting is an isolated app, and this | 102 // If non-empty, the extension we're deleting is an isolated app, and this |
103 // is its directory which we should delete. | 103 // is its directory which we should delete. |
104 FilePath isolated_app_path_; | 104 FilePath isolated_app_path_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(ExtensionDataDeleter); | 106 DISALLOW_COPY_AND_ASSIGN(DataDeleter); |
107 }; | 107 }; |
108 | 108 |
109 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DATA_DELETER_H_ | 109 } // namespace extensions |
| 110 |
| 111 #endif // CHROME_BROWSER_EXTENSIONS_DATA_DELETER_H_ |
OLD | NEW |