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

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

Issue 17518004: Move IndexedDB from WEBKIT_DEPRECATED to dedicated thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing files 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
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_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
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.
53 class CannedBrowsingDataIndexedDBHelper 53 class CannedBrowsingDataIndexedDBHelper
54 : public BrowsingDataIndexedDBHelper { 54 : public BrowsingDataIndexedDBHelper {
55 public: 55 public:
56 // Contains information about an indexed database. 56 // Contains information about an indexed database.
57 struct PendingIndexedDBInfo { 57 struct PendingIndexedDBInfo {
58 PendingIndexedDBInfo(const GURL& origin, const string16& name); 58 PendingIndexedDBInfo(const GURL& origin, const string16& name);
59 ~PendingIndexedDBInfo(); 59 ~PendingIndexedDBInfo();
60 60
61 bool operator<(const PendingIndexedDBInfo& other) const; 61 bool operator<(const PendingIndexedDBInfo& other) const;
62 62
63 GURL origin; 63 GURL origin;
64 string16 name; 64 string16 name;
65 }; 65 };
66 66
67 CannedBrowsingDataIndexedDBHelper(); 67 explicit CannedBrowsingDataIndexedDBHelper(Profile* profile);
68 68
69 // Return a copy of the IndexedDB helper. Only one consumer can use the 69 // Return a copy of the IndexedDB helper. Only one consumer can use the
70 // StartFetching method at a time, so we need to create a copy of the helper 70 // StartFetching method at a time, so we need to create a copy of the helper
71 // every time we instantiate a cookies tree model for it. 71 // every time we instantiate a cookies tree model for it.
72 CannedBrowsingDataIndexedDBHelper* Clone(); 72 CannedBrowsingDataIndexedDBHelper* Clone();
73 73
74 // Add a indexed database to the set of canned indexed databases that is 74 // Add a indexed database to the set of canned indexed databases that is
75 // returned by this helper. 75 // returned by this helper.
76 void AddIndexedDB(const GURL& origin, 76 void AddIndexedDB(const GURL& origin,
77 const string16& name); 77 const string16& name);
(...skipping 15 matching lines...) Expand all
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 ConvertPendingInfoInIndexedDBThread();
104 104
105 void NotifyInUIThread(); 105 void NotifyInUIThread();
106 106
107 // Lock to protect access to pending_indexed_db_info_; 107 // Lock to protect access to pending_indexed_db_info_;
108 mutable base::Lock lock_; 108 mutable base::Lock lock_;
109 109
110 // Access to |pending_indexed_db_info_| is protected by |lock_| since it can 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. 111 // be accessed on the UI and on the IndexedDB thread.
112 std::set<PendingIndexedDBInfo> pending_indexed_db_info_; 112 std::set<PendingIndexedDBInfo> pending_indexed_db_info_;
113 113
114 // Access to |indexed_db_info_| is triggered indirectly via the UI thread and 114 // 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 115 // 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 116 // while |is_fetching_| is true. The flag |is_fetching_| is only accessed on
117 // the UI thread. 117 // the UI thread.
118 // In the context of this class |indexed_db_info_| is only accessed on the UI 118 // In the context of this class |indexed_db_info_| is only accessed on the UI
119 // thread. 119 // thread.
120 std::list<content::IndexedDBInfo> indexed_db_info_; 120 std::list<content::IndexedDBInfo> indexed_db_info_;
121 121
122 // This only mutates on the UI thread. 122 // This only mutates on the UI thread.
123 base::Callback<void(const std::list<content::IndexedDBInfo>&)> 123 base::Callback<void(const std::list<content::IndexedDBInfo>&)>
124 completion_callback_; 124 completion_callback_;
125 125
126 Profile* profile_;
127 scoped_refptr<content::IndexedDBContext> indexed_db_context_;
128
126 // Indicates whether or not we're currently fetching information: 129 // 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 130 // 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. 131 // after we notified the callback in the UI thread.
129 // This only mutates on the UI thread. 132 // This only mutates on the UI thread.
130 bool is_fetching_; 133 bool is_fetching_;
131 134
132 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); 135 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper);
133 }; 136 };
134 137
135 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_ 138 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_INDEXED_DB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698