| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if (status.ok()) | 51 if (status.ok()) |
| 52 return NotificationDatabase::STATUS_OK; | 52 return NotificationDatabase::STATUS_OK; |
| 53 else if (status.IsNotFound()) | 53 else if (status.IsNotFound()) |
| 54 return NotificationDatabase::STATUS_ERROR_NOT_FOUND; | 54 return NotificationDatabase::STATUS_ERROR_NOT_FOUND; |
| 55 else if (status.IsCorruption()) | 55 else if (status.IsCorruption()) |
| 56 return NotificationDatabase::STATUS_ERROR_CORRUPTED; | 56 return NotificationDatabase::STATUS_ERROR_CORRUPTED; |
| 57 else if (status.IsIOError()) | 57 else if (status.IsIOError()) |
| 58 return NotificationDatabase::STATUS_IO_ERROR; | 58 return NotificationDatabase::STATUS_IO_ERROR; |
| 59 else if (status.IsNotSupportedError()) | 59 else if (status.IsNotSupportedError()) |
| 60 return NotificationDatabase::STATUS_NOT_SUPPORTED; | 60 return NotificationDatabase::STATUS_NOT_SUPPORTED; |
| 61 else if (status.IsInvalidArgument()) |
| 62 return NotificationDatabase::STATUS_INVALID_ARGUMENT; |
| 61 | 63 |
| 62 // TODO(cmumford): Once leveldb 1.19 is released add IsInvalidArgument(). | |
| 63 return NotificationDatabase::STATUS_ERROR_FAILED; | 64 return NotificationDatabase::STATUS_ERROR_FAILED; |
| 64 } | 65 } |
| 65 | 66 |
| 66 // Creates a prefix for the data entries based on |origin|. | 67 // Creates a prefix for the data entries based on |origin|. |
| 67 std::string CreateDataPrefix(const GURL& origin) { | 68 std::string CreateDataPrefix(const GURL& origin) { |
| 68 if (!origin.is_valid()) | 69 if (!origin.is_valid()) |
| 69 return kDataKeyPrefix; | 70 return kDataKeyPrefix; |
| 70 | 71 |
| 71 return base::StringPrintf("%s%s%c", kDataKeyPrefix, | 72 return base::StringPrintf("%s%s%c", kDataKeyPrefix, |
| 72 storage::GetIdentifierFromOrigin(origin).c_str(), | 73 storage::GetIdentifierFromOrigin(origin).c_str(), |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 batch.Delete(iter->key()); | 371 batch.Delete(iter->key()); |
| 371 } | 372 } |
| 372 | 373 |
| 373 if (deleted_notification_set->empty()) | 374 if (deleted_notification_set->empty()) |
| 374 return STATUS_OK; | 375 return STATUS_OK; |
| 375 | 376 |
| 376 return LevelDBStatusToStatus(db_->Write(leveldb::WriteOptions(), &batch)); | 377 return LevelDBStatusToStatus(db_->Write(leveldb::WriteOptions(), &batch)); |
| 377 } | 378 } |
| 378 | 379 |
| 379 } // namespace content | 380 } // namespace content |
| OLD | NEW |