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_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 <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 friend class base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper>; | 59 friend class base::RefCountedThreadSafe<BrowsingDataIndexedDBHelper>; |
60 virtual ~BrowsingDataIndexedDBHelper() {} | 60 virtual ~BrowsingDataIndexedDBHelper() {} |
61 }; | 61 }; |
62 | 62 |
63 // This class is an implementation of BrowsingDataIndexedDBHelper that does | 63 // This class is an implementation of BrowsingDataIndexedDBHelper that does |
64 // not fetch its information from the indexed database tracker, but gets them | 64 // not fetch its information from the indexed database tracker, but gets them |
65 // passed as a parameter. | 65 // passed as a parameter. |
66 class CannedBrowsingDataIndexedDBHelper | 66 class CannedBrowsingDataIndexedDBHelper |
67 : public BrowsingDataIndexedDBHelper { | 67 : public BrowsingDataIndexedDBHelper { |
68 public: | 68 public: |
69 // Contains information about an indexed database. | |
70 struct PendingIndexedDBInfo { | |
71 PendingIndexedDBInfo(const GURL& origin, const string16& description); | |
72 ~PendingIndexedDBInfo(); | |
73 | |
74 GURL origin; | |
75 string16 description; | |
76 }; | |
77 | |
69 CannedBrowsingDataIndexedDBHelper(); | 78 CannedBrowsingDataIndexedDBHelper(); |
70 | 79 |
71 // Return a copy of the IndexedDB helper. Only one consumer can use the | 80 // Return a copy of the IndexedDB helper. Only one consumer can use the |
72 // StartFetching method at a time, so we need to create a copy of the helper | 81 // StartFetching method at a time, so we need to create a copy of the helper |
73 // every time we instantiate a cookies tree model for it. | 82 // every time we instantiate a cookies tree model for it. |
74 CannedBrowsingDataIndexedDBHelper* Clone(); | 83 CannedBrowsingDataIndexedDBHelper* Clone(); |
75 | 84 |
76 // Add a indexed database to the set of canned indexed databases that is | 85 // Add a indexed database to the set of canned indexed databases that is |
77 // returned by this helper. | 86 // returned by this helper. |
78 void AddIndexedDB(const GURL& origin, | 87 void AddIndexedDB(const GURL& origin, |
79 const string16& description); | 88 const string16& description); |
80 | 89 |
81 // Clear the list of canned indexed databases. | 90 // Clear the list of canned indexed databases. |
82 void Reset(); | 91 void Reset(); |
83 | 92 |
84 // True if no indexed databases are currently stored. | 93 // True if no indexed databases are currently stored. |
85 bool empty() const; | 94 bool empty() const; |
86 | 95 |
87 // Returns the number of currently stored indexed databases. | 96 // Returns the number of currently stored indexed databases. |
88 size_t GetIndexedDBCount() const; | 97 size_t GetIndexedDBCount() const; |
89 | 98 |
99 // Returns the current list of indexed data bases. | |
100 const std::list<PendingIndexedDBInfo>& pending_indexed_db_info() const { | |
101 return pending_indexed_db_info_; | |
102 } | |
103 | |
90 // BrowsingDataIndexedDBHelper methods. | 104 // BrowsingDataIndexedDBHelper methods. |
91 virtual void StartFetching( | 105 virtual void StartFetching( |
92 const base::Callback<void(const std::list<IndexedDBInfo>&)>& | 106 const base::Callback<void(const std::list<IndexedDBInfo>&)>& |
93 callback) OVERRIDE; | 107 callback) OVERRIDE; |
108 | |
94 virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE {} | 109 virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE {} |
95 | 110 |
96 private: | 111 private: |
97 struct PendingIndexedDBInfo { | |
98 PendingIndexedDBInfo(); | |
99 PendingIndexedDBInfo(const GURL& origin, const string16& description); | |
100 ~PendingIndexedDBInfo(); | |
101 | |
102 GURL origin; | |
103 string16 description; | |
104 }; | |
105 | |
106 virtual ~CannedBrowsingDataIndexedDBHelper(); | 112 virtual ~CannedBrowsingDataIndexedDBHelper(); |
107 | 113 |
108 // Convert the pending indexed db info to indexed db info objects. | 114 // Convert the pending indexed db info to indexed db info objects. |
109 void ConvertPendingInfoInWebKitThread(); | 115 void ConvertPendingInfoInWebKitThread(); |
110 | 116 |
111 void NotifyInUIThread(); | 117 void NotifyInUIThread(); |
112 | 118 |
113 // Lock to protect access to pending_indexed_db_info_; | 119 // Lock to protect access to pending_indexed_db_info_; |
114 mutable base::Lock lock_; | 120 mutable base::Lock lock_; |
115 | 121 |
116 // This may mutate on WEBKIT and UI threads. | 122 // This only mutates on the UI thread. |
bauerb at google
2012/04/27 16:12:50
Do we know that?
markusheintz_
2012/05/10 16:32:36
yes. However it is read on the Webkit thread
| |
117 std::list<PendingIndexedDBInfo> pending_indexed_db_info_; | 123 std::list<PendingIndexedDBInfo> pending_indexed_db_info_; |
118 | 124 |
119 // This only mutates on the WEBKIT thread. | 125 // This only mutates on the WEBKIT thread. |
120 std::list<IndexedDBInfo> indexed_db_info_; | 126 std::list<IndexedDBInfo> indexed_db_info_; |
121 | 127 |
122 // This only mutates on the UI thread. | 128 // This only mutates on the UI thread. |
123 base::Callback<void(const std::list<IndexedDBInfo>&)> completion_callback_; | 129 base::Callback<void(const std::list<IndexedDBInfo>&)> completion_callback_; |
124 | 130 |
125 // Indicates whether or not we're currently fetching information: | 131 // Indicates whether or not we're currently fetching information: |
126 // it's true when StartFetching() is called in the UI thread, and it's reset | 132 // it's true when StartFetching() is called in the UI thread, and it's reset |
127 // after we notified the callback in the UI thread. | 133 // after we notified the callback in the UI thread. |
128 // This only mutates on the UI thread. | 134 // This only mutates on the UI thread. |
129 bool is_fetching_; | 135 bool is_fetching_; |
130 | 136 |
131 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); | 137 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); |
132 }; | 138 }; |
133 | 139 |
134 #endif // CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ | 140 #endif // CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ |
OLD | NEW |