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_DATABASE_HELPER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_DATABASE_HELPER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_DATABASE_HELPER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_DATABASE_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
17 #include "webkit/database/database_tracker.h" | 18 #include "webkit/database/database_tracker.h" |
18 | 19 |
19 class Profile; | 20 class Profile; |
20 | 21 |
21 // This class fetches database information in the FILE thread, and notifies | 22 // This class fetches database information in the FILE thread, and notifies |
22 // the UI thread upon completion. | 23 // the UI thread upon completion. |
(...skipping 27 matching lines...) Expand all Loading... |
50 int64 size; | 51 int64 size; |
51 base::Time last_modified; | 52 base::Time last_modified; |
52 }; | 53 }; |
53 | 54 |
54 explicit BrowsingDataDatabaseHelper(Profile* profile); | 55 explicit BrowsingDataDatabaseHelper(Profile* profile); |
55 | 56 |
56 // Starts the fetching process, which will notify its completion via | 57 // Starts the fetching process, which will notify its completion via |
57 // callback. | 58 // callback. |
58 // This must be called only in the UI thread. | 59 // This must be called only in the UI thread. |
59 virtual void StartFetching( | 60 virtual void StartFetching( |
60 Callback1<const std::list<DatabaseInfo>& >::Type* callback); | 61 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback); |
61 | 62 |
62 // Cancels the notification callback (i.e., the window that created it no | 63 // Cancels the notification callback (i.e., the window that created it no |
63 // longer exists). | 64 // longer exists). |
64 // This must be called only in the UI thread. | 65 // This must be called only in the UI thread. |
65 virtual void CancelNotification(); | 66 virtual void CancelNotification(); |
66 | 67 |
67 // Requests a single database to be deleted in the FILE thread. This must be | 68 // Requests a single database to be deleted in the FILE thread. This must be |
68 // called in the UI thread. | 69 // called in the UI thread. |
69 virtual void DeleteDatabase(const std::string& origin, | 70 virtual void DeleteDatabase(const std::string& origin, |
70 const std::string& name); | 71 const std::string& name); |
71 | 72 |
72 protected: | 73 protected: |
73 friend class base::RefCountedThreadSafe<BrowsingDataDatabaseHelper>; | 74 friend class base::RefCountedThreadSafe<BrowsingDataDatabaseHelper>; |
74 virtual ~BrowsingDataDatabaseHelper(); | 75 virtual ~BrowsingDataDatabaseHelper(); |
75 | 76 |
76 // Notifies the completion callback. This must be called in the UI thread. | 77 // Notifies the completion callback. This must be called in the UI thread. |
77 void NotifyInUIThread(); | 78 void NotifyInUIThread(); |
78 | 79 |
79 // This only mutates in the FILE thread. | 80 // This only mutates in the FILE thread. |
80 std::list<DatabaseInfo> database_info_; | 81 std::list<DatabaseInfo> database_info_; |
81 | 82 |
82 // This only mutates on the UI thread. | 83 // This only mutates on the UI thread. |
83 scoped_ptr<Callback1<const std::list<DatabaseInfo>& >::Type > | 84 base::Callback<void(const std::list<DatabaseInfo>&)> completion_callback_; |
84 completion_callback_; | |
85 | 85 |
86 // Indicates whether or not we're currently fetching information: | 86 // Indicates whether or not we're currently fetching information: |
87 // it's true when StartFetching() is called in the UI thread, and it's reset | 87 // it's true when StartFetching() is called in the UI thread, and it's reset |
88 // after we notify the callback in the UI thread. | 88 // after we notify the callback in the UI thread. |
89 // This only mutates on the UI thread. | 89 // This only mutates on the UI thread. |
90 bool is_fetching_; | 90 bool is_fetching_; |
91 | 91 |
92 private: | 92 private: |
93 // Enumerates all databases. This must be called in the FILE thread. | 93 // Enumerates all databases. This must be called in the FILE thread. |
94 void FetchDatabaseInfoOnFileThread(); | 94 void FetchDatabaseInfoOnFileThread(); |
(...skipping 24 matching lines...) Expand all Loading... |
119 void AddDatabase(const GURL& origin, | 119 void AddDatabase(const GURL& origin, |
120 const std::string& name, | 120 const std::string& name, |
121 const std::string& description); | 121 const std::string& description); |
122 | 122 |
123 // Clear the list of canned databases. | 123 // Clear the list of canned databases. |
124 void Reset(); | 124 void Reset(); |
125 | 125 |
126 // True if no databases are currently stored. | 126 // True if no databases are currently stored. |
127 bool empty() const; | 127 bool empty() const; |
128 | 128 |
129 // BrowsingDataDatabaseHelper methods. | 129 // BrowsingDataDatabaseHelper implementation. |
130 virtual void StartFetching( | 130 virtual void StartFetching( |
131 Callback1<const std::list<DatabaseInfo>& >::Type* callback); | 131 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback) |
132 virtual void CancelNotification() {} | 132 OVERRIDE; |
| 133 virtual void CancelNotification() OVERRIDE {} |
133 | 134 |
134 private: | 135 private: |
135 struct PendingDatabaseInfo { | 136 struct PendingDatabaseInfo { |
136 PendingDatabaseInfo(); | 137 PendingDatabaseInfo(); |
137 PendingDatabaseInfo(const GURL& origin, | 138 PendingDatabaseInfo(const GURL& origin, |
138 const std::string& name, | 139 const std::string& name, |
139 const std::string& description); | 140 const std::string& description); |
140 ~PendingDatabaseInfo(); | 141 ~PendingDatabaseInfo(); |
141 | 142 |
142 GURL origin; | 143 GURL origin; |
(...skipping 11 matching lines...) Expand all Loading... |
154 | 155 |
155 // This may mutate on WEBKIT and UI threads. | 156 // This may mutate on WEBKIT and UI threads. |
156 std::list<PendingDatabaseInfo> pending_database_info_; | 157 std::list<PendingDatabaseInfo> pending_database_info_; |
157 | 158 |
158 Profile* profile_; | 159 Profile* profile_; |
159 | 160 |
160 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataDatabaseHelper); | 161 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataDatabaseHelper); |
161 }; | 162 }; |
162 | 163 |
163 #endif // CHROME_BROWSER_BROWSING_DATA_DATABASE_HELPER_H_ | 164 #endif // CHROME_BROWSER_BROWSING_DATA_DATABASE_HELPER_H_ |
OLD | NEW |