| OLD | NEW |
| 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 #include "content/browser/notifications/notification_database.h" | 5 #include "content/browser/notifications/notification_database.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 int64_t service_worker_registration_id, | 294 int64_t service_worker_registration_id, |
| 295 std::vector<NotificationDatabaseData>* notification_data_vector) const { | 295 std::vector<NotificationDatabaseData>* notification_data_vector) const { |
| 296 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 296 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
| 297 DCHECK(notification_data_vector); | 297 DCHECK(notification_data_vector); |
| 298 | 298 |
| 299 const std::string prefix = CreateDataPrefix(origin); | 299 const std::string prefix = CreateDataPrefix(origin); |
| 300 | 300 |
| 301 leveldb::Slice prefix_slice(prefix); | 301 leveldb::Slice prefix_slice(prefix); |
| 302 | 302 |
| 303 NotificationDatabaseData notification_database_data; | 303 NotificationDatabaseData notification_database_data; |
| 304 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); | 304 std::unique_ptr<leveldb::Iterator> iter( |
| 305 db_->NewIterator(leveldb::ReadOptions())); |
| 305 for (iter->Seek(prefix_slice); iter->Valid(); iter->Next()) { | 306 for (iter->Seek(prefix_slice); iter->Valid(); iter->Next()) { |
| 306 if (!iter->key().starts_with(prefix_slice)) | 307 if (!iter->key().starts_with(prefix_slice)) |
| 307 break; | 308 break; |
| 308 | 309 |
| 309 Status status = DeserializedNotificationData(iter->value().ToString(), | 310 Status status = DeserializedNotificationData(iter->value().ToString(), |
| 310 ¬ification_database_data); | 311 ¬ification_database_data); |
| 311 if (status != STATUS_OK) | 312 if (status != STATUS_OK) |
| 312 return status; | 313 return status; |
| 313 | 314 |
| 314 if (service_worker_registration_id != kInvalidServiceWorkerRegistrationId && | 315 if (service_worker_registration_id != kInvalidServiceWorkerRegistrationId && |
| (...skipping 16 matching lines...) Expand all Loading... |
| 331 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 332 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
| 332 DCHECK(deleted_notification_set); | 333 DCHECK(deleted_notification_set); |
| 333 DCHECK(origin.is_valid()); | 334 DCHECK(origin.is_valid()); |
| 334 | 335 |
| 335 const std::string prefix = CreateDataPrefix(origin); | 336 const std::string prefix = CreateDataPrefix(origin); |
| 336 | 337 |
| 337 leveldb::Slice prefix_slice(prefix); | 338 leveldb::Slice prefix_slice(prefix); |
| 338 leveldb::WriteBatch batch; | 339 leveldb::WriteBatch batch; |
| 339 | 340 |
| 340 NotificationDatabaseData notification_database_data; | 341 NotificationDatabaseData notification_database_data; |
| 341 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(leveldb::ReadOptions())); | 342 std::unique_ptr<leveldb::Iterator> iter( |
| 343 db_->NewIterator(leveldb::ReadOptions())); |
| 342 for (iter->Seek(prefix_slice); iter->Valid(); iter->Next()) { | 344 for (iter->Seek(prefix_slice); iter->Valid(); iter->Next()) { |
| 343 if (!iter->key().starts_with(prefix_slice)) | 345 if (!iter->key().starts_with(prefix_slice)) |
| 344 break; | 346 break; |
| 345 | 347 |
| 346 if (service_worker_registration_id != kInvalidServiceWorkerRegistrationId) { | 348 if (service_worker_registration_id != kInvalidServiceWorkerRegistrationId) { |
| 347 Status status = DeserializedNotificationData(iter->value().ToString(), | 349 Status status = DeserializedNotificationData(iter->value().ToString(), |
| 348 ¬ification_database_data); | 350 ¬ification_database_data); |
| 349 if (status != STATUS_OK) | 351 if (status != STATUS_OK) |
| 350 return status; | 352 return status; |
| 351 | 353 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 368 batch.Delete(iter->key()); | 370 batch.Delete(iter->key()); |
| 369 } | 371 } |
| 370 | 372 |
| 371 if (deleted_notification_set->empty()) | 373 if (deleted_notification_set->empty()) |
| 372 return STATUS_OK; | 374 return STATUS_OK; |
| 373 | 375 |
| 374 return LevelDBStatusToStatus(db_->Write(leveldb::WriteOptions(), &batch)); | 376 return LevelDBStatusToStatus(db_->Write(leveldb::WriteOptions(), &batch)); |
| 375 } | 377 } |
| 376 | 378 |
| 377 } // namespace content | 379 } // namespace content |
| OLD | NEW |