Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_database_helper.h

Issue 17003010: Port BrowsingDataDatabaseHelper to webkit_database::DatabaseIdentifier (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_database_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_DATABASE_HELPER_H_ 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_DATABASE_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_DATABASE_HELPER_H_ 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_DATABASE_HELPER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <set> 9 #include <set>
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/compiler_specific.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 #include "webkit/browser/database/database_tracker.h" 18 #include "webkit/browser/database/database_tracker.h"
19 #include "webkit/common/database/database_identifier.h"
19 20
20 class Profile; 21 class Profile;
21 22
22 // This class fetches database information in the FILE thread, and notifies 23 // This class fetches database information in the FILE thread, and notifies
23 // the UI thread upon completion. 24 // the UI thread upon completion.
24 // A client of this class need to call StartFetching from the UI thread to 25 // A client of this class need to call StartFetching from the UI thread to
25 // initiate the flow, and it'll be notified by the callback in its UI 26 // initiate the flow, and it'll be notified by the callback in its UI
26 // thread at some later point. 27 // thread at some later point.
27 class BrowsingDataDatabaseHelper 28 class BrowsingDataDatabaseHelper
28 : public base::RefCountedThreadSafe<BrowsingDataDatabaseHelper> { 29 : public base::RefCountedThreadSafe<BrowsingDataDatabaseHelper> {
29 public: 30 public:
30 // Contains detailed information about a web database. 31 // Contains detailed information about a web database.
31 struct DatabaseInfo { 32 struct DatabaseInfo {
32 DatabaseInfo(const std::string& host, 33 DatabaseInfo(const webkit_database::DatabaseIdentifier& identifier,
33 const std::string& database_name, 34 const std::string& database_name,
34 const std::string& origin_identifier,
35 const std::string& description, 35 const std::string& description,
36 const std::string& origin,
37 int64 size, 36 int64 size,
38 base::Time last_modified); 37 base::Time last_modified);
39 ~DatabaseInfo(); 38 ~DatabaseInfo();
40 39
41 std::string host; 40 webkit_database::DatabaseIdentifier identifier;
42 std::string database_name; 41 std::string database_name;
43 std::string origin_identifier;
44 std::string description; 42 std::string description;
45 std::string origin;
46 int64 size; 43 int64 size;
47 base::Time last_modified; 44 base::Time last_modified;
48 }; 45 };
49 46
50 explicit BrowsingDataDatabaseHelper(Profile* profile); 47 explicit BrowsingDataDatabaseHelper(Profile* profile);
51 48
52 // Starts the fetching process, which will notify its completion via 49 // Starts the fetching process, which will notify its completion via
53 // callback. 50 // callback.
54 // This must be called only in the UI thread. 51 // This must be called only in the UI thread.
55 virtual void StartFetching( 52 virtual void StartFetching(
56 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback); 53 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback);
57 54
58 // Requests a single database to be deleted in the FILE thread. This must be 55 // Requests a single database to be deleted in the FILE thread. This must be
59 // called in the UI thread. 56 // called in the UI thread.
60 virtual void DeleteDatabase(const std::string& origin, 57 virtual void DeleteDatabase(const std::string& origin_identifier,
61 const std::string& name); 58 const std::string& name);
62 59
63 protected: 60 protected:
64 friend class base::RefCountedThreadSafe<BrowsingDataDatabaseHelper>; 61 friend class base::RefCountedThreadSafe<BrowsingDataDatabaseHelper>;
65 virtual ~BrowsingDataDatabaseHelper(); 62 virtual ~BrowsingDataDatabaseHelper();
66 63
67 // Notifies the completion callback. This must be called in the UI thread. 64 // Notifies the completion callback. This must be called in the UI thread.
68 void NotifyInUIThread(); 65 void NotifyInUIThread();
69 66
70 // Access to |database_info_| is triggered indirectly via the UI thread and 67 // Access to |database_info_| is triggered indirectly via the UI thread and
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const std::set<PendingDatabaseInfo>& GetPendingDatabaseInfo(); 139 const std::set<PendingDatabaseInfo>& GetPendingDatabaseInfo();
143 140
144 // BrowsingDataDatabaseHelper implementation. 141 // BrowsingDataDatabaseHelper implementation.
145 virtual void StartFetching( 142 virtual void StartFetching(
146 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback) 143 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback)
147 OVERRIDE; 144 OVERRIDE;
148 145
149 private: 146 private:
150 virtual ~CannedBrowsingDataDatabaseHelper(); 147 virtual ~CannedBrowsingDataDatabaseHelper();
151 148
152 // Converts the pending database info structs to database info structs.
153 void ConvertInfoInWebKitThread();
154
155 // Used to protect access to pending_database_info_.
156 mutable base::Lock lock_;
157
158 // Access to |pending_database_info_| is protected by |lock_| since it may
159 // be accessed on the UI or the WEBKIT thread.
160 std::set<PendingDatabaseInfo> pending_database_info_; 149 std::set<PendingDatabaseInfo> pending_database_info_;
161 150
162 Profile* profile_; 151 Profile* profile_;
163 152
164 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataDatabaseHelper); 153 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataDatabaseHelper);
165 }; 154 };
166 155
167 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_DATABASE_HELPER_H_ 156 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_DATABASE_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_database_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698