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 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 21 matching lines...) Expand all Loading... |
32 // stored in |profile|'s user data directory. | 32 // stored in |profile|'s user data directory. |
33 static BrowsingDataIndexedDBHelper* Create( | 33 static BrowsingDataIndexedDBHelper* Create( |
34 content::IndexedDBContext* context); | 34 content::IndexedDBContext* context); |
35 | 35 |
36 // Starts the fetching process, which will notify its completion via | 36 // Starts the fetching process, which will notify its completion via |
37 // callback. | 37 // callback. |
38 // This must be called only in the UI thread. | 38 // This must be called only in the UI thread. |
39 virtual void StartFetching( | 39 virtual void StartFetching( |
40 const base::Callback<void(const std::list<content::IndexedDBInfo>&)>& | 40 const base::Callback<void(const std::list<content::IndexedDBInfo>&)>& |
41 callback) = 0; | 41 callback) = 0; |
42 // Requests a single indexed database to be deleted in the WEBKIT thread. | 42 // Requests a single indexed database to be deleted in the IndexedDB thread. |
43 virtual void DeleteIndexedDB(const GURL& origin) = 0; | 43 virtual void DeleteIndexedDB(const GURL& origin) = 0; |
44 | 44 |
45 protected: | 45 protected: |
46 friend class base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper>; | 46 friend class base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper>; |
47 virtual ~BrowsingDataIndexedDBHelper() {} | 47 virtual ~BrowsingDataIndexedDBHelper() {} |
48 }; | 48 }; |
49 | 49 |
50 // This class is an implementation of BrowsingDataIndexedDBHelper that does | 50 // This class is an implementation of BrowsingDataIndexedDBHelper that does |
51 // not fetch its information from the indexed database tracker, but gets them | 51 // not fetch its information from the indexed database tracker, but gets them |
52 // passed as a parameter. | 52 // passed as a parameter. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 virtual void StartFetching( | 93 virtual void StartFetching( |
94 const base::Callback<void(const std::list<content::IndexedDBInfo>&)>& | 94 const base::Callback<void(const std::list<content::IndexedDBInfo>&)>& |
95 callback) OVERRIDE; | 95 callback) OVERRIDE; |
96 | 96 |
97 virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE {} | 97 virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE {} |
98 | 98 |
99 private: | 99 private: |
100 virtual ~CannedBrowsingDataIndexedDBHelper(); | 100 virtual ~CannedBrowsingDataIndexedDBHelper(); |
101 | 101 |
102 // Convert the pending indexed db info to indexed db info objects. | 102 // Convert the pending indexed db info to indexed db info objects. |
103 void ConvertPendingInfoInWebKitThread(); | 103 void ConvertPendingInfo(); |
104 | 104 |
105 void NotifyInUIThread(); | |
106 | |
107 // Lock to protect access to pending_indexed_db_info_; | |
108 mutable base::Lock lock_; | |
109 | |
110 // Access to |pending_indexed_db_info_| is protected by |lock_| since it can | |
111 // be accessed on the UI and on the WEBKIT thread. | |
112 std::set<PendingIndexedDBInfo> pending_indexed_db_info_; | 105 std::set<PendingIndexedDBInfo> pending_indexed_db_info_; |
113 | 106 |
114 // Access to |indexed_db_info_| is triggered indirectly via the UI thread and | 107 // Access to |indexed_db_info_| is triggered indirectly via the UI thread and |
115 // guarded by |is_fetching_|. This means |indexed_db_info_| is only accessed | 108 // guarded by |is_fetching_|. This means |indexed_db_info_| is only accessed |
116 // while |is_fetching_| is true. The flag |is_fetching_| is only accessed on | 109 // while |is_fetching_| is true. The flag |is_fetching_| is only accessed on |
117 // the UI thread. | 110 // the UI thread. |
118 // In the context of this class |indexed_db_info_| is only accessed on the UI | 111 // In the context of this class |indexed_db_info_| is only accessed on the UI |
119 // thread. | 112 // thread. |
120 std::list<content::IndexedDBInfo> indexed_db_info_; | 113 std::list<content::IndexedDBInfo> indexed_db_info_; |
121 | 114 |
122 // This only mutates on the UI thread. | 115 // This only mutates on the UI thread. |
123 base::Callback<void(const std::list<content::IndexedDBInfo>&)> | 116 base::Callback<void(const std::list<content::IndexedDBInfo>&)> |
124 completion_callback_; | 117 completion_callback_; |
125 | 118 |
126 // Indicates whether or not we're currently fetching information: | 119 // Indicates whether or not we're currently fetching information: |
127 // it's true when StartFetching() is called in the UI thread, and it's reset | 120 // it's true when StartFetching() is called in the UI thread, and it's reset |
128 // after we notified the callback in the UI thread. | 121 // after we notified the callback in the UI thread. |
129 // This only mutates on the UI thread. | 122 // This only mutates on the UI thread. |
130 bool is_fetching_; | 123 bool is_fetching_; |
131 | 124 |
132 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); | 125 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); |
133 }; | 126 }; |
134 | 127 |
135 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ | 128 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ |
OLD | NEW |