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_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <list> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | |
12 | 12 |
13 #include "base/callback_old.h" | 13 #include "base/callback_old.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 | 20 |
21 class Profile; | 21 class Profile; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 int64 size; | 57 int64 size; |
58 base::Time last_modified; | 58 base::Time last_modified; |
59 }; | 59 }; |
60 | 60 |
61 explicit BrowsingDataLocalStorageHelper(Profile* profile); | 61 explicit BrowsingDataLocalStorageHelper(Profile* profile); |
62 | 62 |
63 // Starts the fetching process, which will notify its completion via | 63 // Starts the fetching process, which will notify its completion via |
64 // callback. | 64 // callback. |
65 // This must be called only in the UI thread. | 65 // This must be called only in the UI thread. |
66 virtual void StartFetching( | 66 virtual void StartFetching( |
67 Callback1<const std::vector<LocalStorageInfo>& >::Type* callback); | 67 Callback1<const std::list<LocalStorageInfo>& >::Type* callback); |
68 // Cancels the notification callback (i.e., the window that created it no | 68 // Cancels the notification callback (i.e., the window that created it no |
69 // longer exists). | 69 // longer exists). |
70 // This must be called only in the UI thread. | 70 // This must be called only in the UI thread. |
71 virtual void CancelNotification(); | 71 virtual void CancelNotification(); |
72 // Requests a single local storage file to be deleted in the WEBKIT thread. | 72 // Requests a single local storage file to be deleted in the WEBKIT thread. |
73 virtual void DeleteLocalStorageFile(const FilePath& file_path); | 73 virtual void DeleteLocalStorageFile(const FilePath& file_path); |
74 | 74 |
75 protected: | 75 protected: |
76 friend class base::RefCountedThreadSafe<BrowsingDataLocalStorageHelper>; | 76 friend class base::RefCountedThreadSafe<BrowsingDataLocalStorageHelper>; |
77 virtual ~BrowsingDataLocalStorageHelper(); | 77 virtual ~BrowsingDataLocalStorageHelper(); |
78 | 78 |
79 // Notifies the completion callback in the UI thread. | 79 // Notifies the completion callback in the UI thread. |
80 void NotifyInUIThread(); | 80 void NotifyInUIThread(); |
81 | 81 |
82 Profile* profile_; | 82 Profile* profile_; |
83 | 83 |
84 // This only mutates on the UI thread. | 84 // This only mutates on the UI thread. |
85 scoped_ptr<Callback1<const std::vector<LocalStorageInfo>& >::Type > | 85 scoped_ptr<Callback1<const std::list<LocalStorageInfo>& >::Type > |
86 completion_callback_; | 86 completion_callback_; |
87 | 87 |
88 // Indicates whether or not we're currently fetching information: | 88 // Indicates whether or not we're currently fetching information: |
89 // it's true when StartFetching() is called in the UI thread, and it's reset | 89 // it's true when StartFetching() is called in the UI thread, and it's reset |
90 // after we notified the callback in the UI thread. | 90 // after we notified the callback in the UI thread. |
91 // This only mutates on the UI thread. | 91 // This only mutates on the UI thread. |
92 bool is_fetching_; | 92 bool is_fetching_; |
93 | 93 |
94 // This only mutates in the WEBKIT thread. | 94 // This only mutates in the WEBKIT thread. |
95 std::vector<LocalStorageInfo> local_storage_info_; | 95 std::list<LocalStorageInfo> local_storage_info_; |
96 | 96 |
97 private: | 97 private: |
98 // Enumerates all local storage files in the WEBKIT thread. | 98 // Enumerates all local storage files in the WEBKIT thread. |
99 void FetchLocalStorageInfoInWebKitThread(); | 99 void FetchLocalStorageInfoInWebKitThread(); |
100 // Delete a single local storage file in the WEBKIT thread. | 100 // Delete a single local storage file in the WEBKIT thread. |
101 void DeleteLocalStorageFileInWebKitThread(const FilePath& file_path); | 101 void DeleteLocalStorageFileInWebKitThread(const FilePath& file_path); |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(BrowsingDataLocalStorageHelper); | 103 DISALLOW_COPY_AND_ASSIGN(BrowsingDataLocalStorageHelper); |
104 }; | 104 }; |
105 | 105 |
(...skipping 15 matching lines...) Expand all Loading... |
121 void AddLocalStorage(const GURL& origin); | 121 void AddLocalStorage(const GURL& origin); |
122 | 122 |
123 // Clear the list of canned local storages. | 123 // Clear the list of canned local storages. |
124 void Reset(); | 124 void Reset(); |
125 | 125 |
126 // True if no local storages are currently stored. | 126 // True if no local storages are currently stored. |
127 bool empty() const; | 127 bool empty() const; |
128 | 128 |
129 // BrowsingDataLocalStorageHelper methods. | 129 // BrowsingDataLocalStorageHelper methods. |
130 virtual void StartFetching( | 130 virtual void StartFetching( |
131 Callback1<const std::vector<LocalStorageInfo>& >::Type* callback); | 131 Callback1<const std::list<LocalStorageInfo>& >::Type* callback); |
132 virtual void CancelNotification() {} | 132 virtual void CancelNotification() {} |
133 | 133 |
134 private: | 134 private: |
135 virtual ~CannedBrowsingDataLocalStorageHelper(); | 135 virtual ~CannedBrowsingDataLocalStorageHelper(); |
136 | 136 |
137 // Convert the pending local storage info to local storage info objects. | 137 // Convert the pending local storage info to local storage info objects. |
138 void ConvertPendingInfoInWebKitThread(); | 138 void ConvertPendingInfoInWebKitThread(); |
139 | 139 |
140 // Used to protect access to pending_local_storage_info_. | 140 // Used to protect access to pending_local_storage_info_. |
141 mutable base::Lock lock_; | 141 mutable base::Lock lock_; |
142 | 142 |
143 // May mutate on WEBKIT and UI threads. | 143 // May mutate on WEBKIT and UI threads. |
144 std::set<GURL> pending_local_storage_info_; | 144 std::set<GURL> pending_local_storage_info_; |
145 | 145 |
146 Profile* profile_; | 146 Profile* profile_; |
147 | 147 |
148 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataLocalStorageHelper); | 148 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataLocalStorageHelper); |
149 }; | 149 }; |
150 | 150 |
151 #endif // CHROME_BROWSER_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ | 151 #endif // CHROME_BROWSER_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ |
OLD | NEW |