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

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

Issue 10092013: Display third party cookies and site data counts in the WebsiteSettings UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Fix CannedBrowsingDataDatabaseHelperTest.*" Created 8 years, 7 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_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 <set>
10 #include <string> 11 #include <string>
11 12
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/file_path.h" 15 #include "base/file_path.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "base/time.h" 19 #include "base/time.h"
19 #include "chrome/common/url_constants.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 21
22 class Profile; 22 class Profile;
23 23
24 // BrowsingDataIndexedDBHelper is an interface for classes dealing with 24 // BrowsingDataIndexedDBHelper is an interface for classes dealing with
25 // aggregating and deleting browsing data stored in indexed databases. A 25 // aggregating and deleting browsing data stored in indexed databases. A
26 // client of this class need to call StartFetching from the UI thread to 26 // client of this class need to call StartFetching from the UI thread to
27 // initiate the flow, and it'll be notified by the callback in its UI thread at 27 // initiate the flow, and it'll be notified by the callback in its UI thread at
28 // some later point. 28 // some later point.
29 class BrowsingDataIndexedDBHelper 29 class BrowsingDataIndexedDBHelper
(...skipping 29 matching lines...) Expand all
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& name);
72 ~PendingIndexedDBInfo();
73
74 bool operator<(const PendingIndexedDBInfo& other) const;
75
76 GURL origin;
77 string16 name;
78 };
79
69 CannedBrowsingDataIndexedDBHelper(); 80 CannedBrowsingDataIndexedDBHelper();
70 81
71 // Return a copy of the IndexedDB helper. Only one consumer can use the 82 // 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 83 // 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. 84 // every time we instantiate a cookies tree model for it.
74 CannedBrowsingDataIndexedDBHelper* Clone(); 85 CannedBrowsingDataIndexedDBHelper* Clone();
75 86
76 // Add a indexed database to the set of canned indexed databases that is 87 // Add a indexed database to the set of canned indexed databases that is
77 // returned by this helper. 88 // returned by this helper.
78 void AddIndexedDB(const GURL& origin, 89 void AddIndexedDB(const GURL& origin,
79 const string16& description); 90 const string16& name);
80 91
81 // Clear the list of canned indexed databases. 92 // Clear the list of canned indexed databases.
82 void Reset(); 93 void Reset();
83 94
84 // True if no indexed databases are currently stored. 95 // True if no indexed databases are currently stored.
85 bool empty() const; 96 bool empty() const;
86 97
87 // Returns the number of currently stored indexed databases. 98 // Returns the number of currently stored indexed databases.
88 size_t GetIndexedDBCount() const; 99 size_t GetIndexedDBCount() const;
89 100
101 // Returns the current list of indexed data bases.
102 const std::set<CannedBrowsingDataIndexedDBHelper::PendingIndexedDBInfo>&
103 GetIndexedDBInfo() const;
104
90 // BrowsingDataIndexedDBHelper methods. 105 // BrowsingDataIndexedDBHelper methods.
91 virtual void StartFetching( 106 virtual void StartFetching(
92 const base::Callback<void(const std::list<IndexedDBInfo>&)>& 107 const base::Callback<void(const std::list<IndexedDBInfo>&)>&
93 callback) OVERRIDE; 108 callback) OVERRIDE;
109
94 virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE {} 110 virtual void DeleteIndexedDB(const GURL& origin) OVERRIDE {}
95 111
96 private: 112 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(); 113 virtual ~CannedBrowsingDataIndexedDBHelper();
107 114
108 // Convert the pending indexed db info to indexed db info objects. 115 // Convert the pending indexed db info to indexed db info objects.
109 void ConvertPendingInfoInWebKitThread(); 116 void ConvertPendingInfoInWebKitThread();
110 117
111 void NotifyInUIThread(); 118 void NotifyInUIThread();
112 119
113 // Lock to protect access to pending_indexed_db_info_; 120 // Lock to protect access to pending_indexed_db_info_;
114 mutable base::Lock lock_; 121 mutable base::Lock lock_;
115 122
116 // This may mutate on WEBKIT and UI threads. 123 // Access to |pending_indexed_db_info_| is protected by |lock_| since it can
117 std::list<PendingIndexedDBInfo> pending_indexed_db_info_; 124 // be accessed on the UI and on the WEBKIT thread.
125 std::set<PendingIndexedDBInfo> pending_indexed_db_info_;
118 126
119 // This only mutates on the WEBKIT thread. 127 // Access to |indexed_db_info_| is triggered indirectly via the UI thread and
128 // guarded by |is_fetching_|. This means |indexed_db_info_| is only accessed
129 // while |is_fetching_| is true. The flag |is_fetching_| is only accessed on
130 // the UI thread.
131 // In the context of this class |indexed_db_info_| is only accessed on the UI
132 // thread.
120 std::list<IndexedDBInfo> indexed_db_info_; 133 std::list<IndexedDBInfo> indexed_db_info_;
121 134
122 // This only mutates on the UI thread. 135 // This only mutates on the UI thread.
123 base::Callback<void(const std::list<IndexedDBInfo>&)> completion_callback_; 136 base::Callback<void(const std::list<IndexedDBInfo>&)> completion_callback_;
124 137
125 // Indicates whether or not we're currently fetching information: 138 // 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 139 // 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. 140 // after we notified the callback in the UI thread.
128 // This only mutates on the UI thread. 141 // This only mutates on the UI thread.
129 bool is_fetching_; 142 bool is_fetching_;
130 143
131 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper); 144 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataIndexedDBHelper);
132 }; 145 };
133 146
134 #endif // CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_ 147 #endif // CHROME_BROWSER_BROWSING_DATA_INDEXED_DB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_file_system_helper.cc ('k') | chrome/browser/browsing_data_indexed_db_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698