| 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 15 matching lines...) Expand all Loading... |
| 26 // initiate the flow, and it'll be notified by the callback in its UI thread at | 26 // initiate the flow, and it'll be notified by the callback in its UI thread at |
| 27 // some later point. | 27 // some later point. |
| 28 class BrowsingDataIndexedDBHelper | 28 class BrowsingDataIndexedDBHelper |
| 29 : public base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper> { | 29 : public base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper> { |
| 30 public: | 30 public: |
| 31 // Create a BrowsingDataIndexedDBHelper instance for the indexed databases | 31 // Create a BrowsingDataIndexedDBHelper instance for the indexed databases |
| 32 // stored in |context|'s associated profile's user data directory. | 32 // stored in |context|'s associated profile's user data directory. |
| 33 explicit BrowsingDataIndexedDBHelper(content::IndexedDBContext* context); | 33 explicit BrowsingDataIndexedDBHelper(content::IndexedDBContext* context); |
| 34 | 34 |
| 35 // Starts the fetching process, which will notify its completion via | 35 // Starts the fetching process, which will notify its completion via |
| 36 // |callback|. This must be called only in the UI thread. | 36 // |callback|. This must be called only on the UI thread. |
| 37 virtual void StartFetching( | 37 virtual void StartFetching( |
| 38 const base::Callback<void(const std::list<content::IndexedDBInfo>&)>& | 38 const base::Callback<void(const std::list<content::IndexedDBInfo>&)>& |
| 39 callback); | 39 callback); |
| 40 // Requests a single indexed database to be deleted in the IndexedDB thread. | 40 // Requests a single indexed database to be deleted in the IndexedDB thread. |
| 41 virtual void DeleteIndexedDB(const GURL& origin); | 41 virtual void DeleteIndexedDB(const GURL& origin); |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 virtual ~BrowsingDataIndexedDBHelper(); | 44 virtual ~BrowsingDataIndexedDBHelper(); |
| 45 | 45 |
| 46 scoped_refptr<content::IndexedDBContext> indexed_db_context_; | 46 scoped_refptr<content::IndexedDBContext> indexed_db_context_; |
| 47 | 47 |
| 48 // Access to |indexed_db_info_| is triggered indirectly via the UI thread and | 48 // Access to |indexed_db_info_| is triggered indirectly via the UI thread and |
| 49 // guarded by |is_fetching_|. This means |indexed_db_info_| is only accessed | 49 // guarded by |is_fetching_|. This means |indexed_db_info_| is only accessed |
| 50 // while |is_fetching_| is true. The flag |is_fetching_| is only accessed on | 50 // while |is_fetching_| is true. The flag |is_fetching_| is only accessed on |
| 51 // the UI thread. | 51 // the UI thread. |
| 52 // In the context of this class |indexed_db_info_| is only accessed on the | 52 // In the context of this class |indexed_db_info_| is only accessed on the |
| 53 // context's IndexedDB thread. | 53 // context's IndexedDB thread. |
| 54 std::list<content::IndexedDBInfo> indexed_db_info_; | 54 std::list<content::IndexedDBInfo> indexed_db_info_; |
| 55 | 55 |
| 56 // This member is only mutated on the UI thread. | 56 // This member is only mutated on the UI thread. |
| 57 base::Callback<void(const std::list<content::IndexedDBInfo>&)> | 57 base::Callback<void(const std::list<content::IndexedDBInfo>&)> |
| 58 completion_callback_; | 58 completion_callback_; |
| 59 | 59 |
| 60 // Indicates whether or not we're currently fetching information: | 60 // Indicates whether or not we're currently fetching information: |
| 61 // it's true when StartFetching() is called in the UI thread, and it's reset | 61 // it's true when StartFetching() is called in the UI thread, and it's reset |
| 62 // after we notified the callback in the UI thread. | 62 // after we notified the callback in the UI thread. |
| 63 // This only mutates on the UI thread. | 63 // This member is only mutated on the UI thread. |
| 64 bool is_fetching_; | 64 bool is_fetching_; |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 friend class base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper>; | 67 friend class base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper>; |
| 68 | 68 |
| 69 // Enumerates all indexed database files in the IndexedDB thread. | 69 // Enumerates all indexed database files in the IndexedDB thread. |
| 70 void FetchIndexedDBInfoInIndexedDBThread(); | 70 void FetchIndexedDBInfoInIndexedDBThread(); |
| 71 // Notifies the completion callback in the UI thread. | 71 // Notifies the completion callback in the UI thread. |
| 72 void NotifyInUIThread(); | 72 void NotifyInUIThread(); |
| 73 // Delete a single indexed database in the IndexedDB thread. | 73 // Delete a single indexed database in the IndexedDB thread. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 private: | 128 private: |
| 129 virtual ~CannedBrowsingDataIndexedDBHelper(); | 129 virtual ~CannedBrowsingDataIndexedDBHelper(); |
| 130 | 130 |
| 131 std::set<PendingIndexedDBInfo> pending_indexed_db_info_; | 131 std::set<PendingIndexedDBInfo> pending_indexed_db_info_; |
| 132 | 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); | 133 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ | 136 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ |
| OLD | NEW |