OLD | NEW |
---|---|
1 // Copyright (c) 2010 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_INDEXED_DB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
15 #include "base/scoped_ptr.h" | |
16 #include "base/synchronization/lock.h" | |
15 #include "base/time.h" | 17 #include "base/time.h" |
16 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
17 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
18 | 20 |
19 class Profile; | 21 class Profile; |
20 | 22 |
21 // BrowsingDataIndexedDBHelper is an interface for classes dealing with | 23 // BrowsingDataIndexedDBHelper is an interface for classes dealing with |
22 // aggregating and deleting browsing data stored in indexed databases. A | 24 // aggregating and deleting browsing data stored in indexed databases. A |
23 // client of this class need to call StartFetching from the UI thread to | 25 // client of this class need to call StartFetching from the UI thread to |
24 // 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 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 // True if no indexed databases are currently stored. | 96 // True if no indexed databases are currently stored. |
95 bool empty() const; | 97 bool empty() const; |
96 | 98 |
97 // BrowsingDataIndexedDBHelper methods. | 99 // BrowsingDataIndexedDBHelper methods. |
98 virtual void StartFetching( | 100 virtual void StartFetching( |
99 Callback1<const std::vector<IndexedDBInfo>& >::Type* callback); | 101 Callback1<const std::vector<IndexedDBInfo>& >::Type* callback); |
100 virtual void CancelNotification() {} | 102 virtual void CancelNotification() {} |
101 virtual void DeleteIndexedDBFile(const FilePath& file_path) {} | 103 virtual void DeleteIndexedDBFile(const FilePath& file_path) {} |
102 | 104 |
103 private: | 105 private: |
106 struct PendingIndexedDBInfo { | |
107 PendingIndexedDBInfo(); | |
108 PendingIndexedDBInfo(const GURL& origin, const string16& description); | |
109 ~PendingIndexedDBInfo(); | |
110 | |
111 GURL origin; | |
112 string16 description; | |
113 }; | |
114 | |
104 virtual ~CannedBrowsingDataIndexedDBHelper(); | 115 virtual ~CannedBrowsingDataIndexedDBHelper(); |
105 | 116 |
117 // Convert the pending indexed db info to indexed db info objects. | |
118 void ConvertPendingInfoInWebKitThread(); | |
bulach
2011/02/22 22:34:01
as above
| |
119 | |
120 void NotifyInUIThread(); | |
121 | |
106 Profile* profile_; | 122 Profile* profile_; |
107 | 123 |
124 // Lock to protect access to pending_indexed_db_info_; | |
125 mutable base::Lock lock_; | |
126 | |
127 // This may mutate on WEBKIT and UI threads. | |
128 std::vector<PendingIndexedDBInfo> pending_indexed_db_info_; | |
129 | |
130 // This only mutates on the WEBKIT thread. | |
108 std::vector<IndexedDBInfo> indexed_db_info_; | 131 std::vector<IndexedDBInfo> indexed_db_info_; |
109 | 132 |
133 // This only mutates on the UI thread. | |
134 scoped_ptr<Callback1<const std::vector<IndexedDBInfo>& >::Type > | |
135 completion_callback_; | |
136 | |
137 // Indicates whether or not we're currently fetching information: | |
138 // it's true when StartFetching() is called in the UI thread, and it's reset | |
139 // after we notified the callback in the UI thread. | |
140 // This only mutates on the UI thread. | |
141 bool is_fetching_; | |
142 | |
110 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); | 143 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); |
111 }; | 144 }; |
112 | 145 |
113 #endif // CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ | 146 #endif // CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ |
OLD | NEW |