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

Side by Side Diff: content/browser/notifications/notification_database.h

Issue 2223943002: Eagerly delete replaced notifications from the database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Eagerly delete replaced notifications from the database Created 4 years, 4 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
« no previous file with comments | « no previous file | content/browser/notifications/notification_database.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_
6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ 6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const GURL& origin, 112 const GURL& origin,
113 const NotificationDatabaseData& notification_database_data, 113 const NotificationDatabaseData& notification_database_data,
114 int64_t* notification_id); 114 int64_t* notification_id);
115 115
116 // Deletes all data associated with the notification identified by 116 // Deletes all data associated with the notification identified by
117 // |notification_id| belonging to |origin| from the database. Returns the 117 // |notification_id| belonging to |origin| from the database. Returns the
118 // status code of the deletion operation. Note that it is not considered a 118 // status code of the deletion operation. Note that it is not considered a
119 // failure if the to-be-deleted notification does not exist. 119 // failure if the to-be-deleted notification does not exist.
120 Status DeleteNotificationData(int64_t notification_id, const GURL& origin); 120 Status DeleteNotificationData(int64_t notification_id, const GURL& origin);
121 121
122 // Deletes all data associated with |origin| from the database, and appends 122 // Deletes all data associated with |origin| from the database, optionally
123 // the deleted notification ids to |deleted_notification_set|. Returns the 123 // filtered by the |tag|, and appends the deleted notification ids to
124 // status code of the deletion operation. 124 // |deleted_notification_set|. Returns the status code of the deletion
125 // operation.
125 Status DeleteAllNotificationDataForOrigin( 126 Status DeleteAllNotificationDataForOrigin(
126 const GURL& origin, 127 const GURL& origin,
128 const std::string& tag,
127 std::set<int64_t>* deleted_notification_set); 129 std::set<int64_t>* deleted_notification_set);
128 130
129 // Deletes all data associated with the |service_worker_registration_id| 131 // Deletes all data associated with the |service_worker_registration_id|
130 // belonging to |origin| from the database, and appends the deleted 132 // belonging to |origin| from the database, and appends the deleted
131 // notification ids to |deleted_notification_set|. Returns the status code 133 // notification ids to |deleted_notification_set|. Returns the status code
132 // of the deletion operation. 134 // of the deletion operation.
133 Status DeleteAllNotificationDataForServiceWorkerRegistration( 135 Status DeleteAllNotificationDataForServiceWorkerRegistration(
134 const GURL& origin, 136 const GURL& origin,
135 int64_t service_worker_registration_id, 137 int64_t service_worker_registration_id,
136 std::set<int64_t>* deleted_notification_set); 138 std::set<int64_t>* deleted_notification_set);
(...skipping 23 matching lines...) Expand all
160 // data for |origin| will be read. If both are set, then all notification data 162 // data for |origin| will be read. If both are set, then all notification data
161 // for the given |service_worker_registration_id| will be read. 163 // for the given |service_worker_registration_id| will be read.
162 Status ReadAllNotificationDataInternal( 164 Status ReadAllNotificationDataInternal(
163 const GURL& origin, 165 const GURL& origin,
164 int64_t service_worker_registration_id, 166 int64_t service_worker_registration_id,
165 std::vector<NotificationDatabaseData>* notification_data_vector) const; 167 std::vector<NotificationDatabaseData>* notification_data_vector) const;
166 168
167 // Deletes all notification data with the given constraints. |origin| must 169 // Deletes all notification data with the given constraints. |origin| must
168 // always be set - use Destroy() when the goal is to empty the database. If 170 // always be set - use Destroy() when the goal is to empty the database. If
169 // |service_worker_registration_id| is invalid, all notification data for the 171 // |service_worker_registration_id| is invalid, all notification data for the
170 // |origin| will be deleted. 172 // |origin| will be deleted, optionally filtered by the |tag| when non-empty.
171 // All deleted notification ids will be written to |deleted_notification_set|. 173 // All deleted notification ids will be written to |deleted_notification_set|.
172 Status DeleteAllNotificationDataInternal( 174 Status DeleteAllNotificationDataInternal(
173 const GURL& origin, 175 const GURL& origin,
176 const std::string& tag,
174 int64_t service_worker_registration_id, 177 int64_t service_worker_registration_id,
175 std::set<int64_t>* deleted_notification_set); 178 std::set<int64_t>* deleted_notification_set);
176 179
177 // Returns whether the database has been opened. 180 // Returns whether the database has been opened.
178 bool IsOpen() const { return db_ != nullptr; } 181 bool IsOpen() const { return db_ != nullptr; }
179 182
180 // Returns whether the database should only exist in memory. 183 // Returns whether the database should only exist in memory.
181 bool IsInMemoryDatabase() const { return path_.empty(); } 184 bool IsInMemoryDatabase() const { return path_.empty(); }
182 185
183 // Exposes the LevelDB database used to back this notification database. 186 // Exposes the LevelDB database used to back this notification database.
(...skipping 14 matching lines...) Expand all
198 State state_ = STATE_UNINITIALIZED; 201 State state_ = STATE_UNINITIALIZED;
199 202
200 base::SequenceChecker sequence_checker_; 203 base::SequenceChecker sequence_checker_;
201 204
202 DISALLOW_COPY_AND_ASSIGN(NotificationDatabase); 205 DISALLOW_COPY_AND_ASSIGN(NotificationDatabase);
203 }; 206 };
204 207
205 } // namespace content 208 } // namespace content
206 209
207 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ 210 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/notifications/notification_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698