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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "content/browser/notifications/notification_database_data_conversions.h
" | 12 #include "content/browser/notifications/notification_database_data_conversions.h
" |
13 #include "content/common/service_worker/service_worker_types.h" | 13 #include "content/common/service_worker/service_worker_types.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/notification_database_data.h" | 15 #include "content/public/browser/notification_database_data.h" |
16 #include "storage/common/database/database_identifier.h" | 16 #include "storage/common/database/database_identifier.h" |
| 17 #include "third_party/leveldatabase/env_chromium.h" |
17 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 18 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
18 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 19 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
19 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 20 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
20 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 21 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
22 | 23 |
23 // Notification LevelDB database schema (in alphabetized order) | 24 // Notification LevelDB database schema (in alphabetized order) |
24 // ======================= | 25 // ======================= |
25 // | 26 // |
26 // key: "DATA:" <origin identifier> '\x00' <notification_id> | 27 // key: "DATA:" <origin identifier> '\x00' <notification_id> |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 if (IsInMemoryDatabase() || | 108 if (IsInMemoryDatabase() || |
108 !base::PathExists(path_) || | 109 !base::PathExists(path_) || |
109 base::IsDirectoryEmpty(path_)) { | 110 base::IsDirectoryEmpty(path_)) { |
110 return NotificationDatabase::STATUS_ERROR_NOT_FOUND; | 111 return NotificationDatabase::STATUS_ERROR_NOT_FOUND; |
111 } | 112 } |
112 } | 113 } |
113 | 114 |
114 leveldb::Options options; | 115 leveldb::Options options; |
115 options.create_if_missing = create_if_missing; | 116 options.create_if_missing = create_if_missing; |
116 options.paranoid_checks = true; | 117 options.paranoid_checks = true; |
| 118 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
117 if (IsInMemoryDatabase()) { | 119 if (IsInMemoryDatabase()) { |
118 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); | 120 env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
119 options.env = env_.get(); | 121 options.env = env_.get(); |
120 } | 122 } |
121 | 123 |
122 leveldb::DB* db = nullptr; | 124 leveldb::DB* db = nullptr; |
123 Status status = LevelDBStatusToStatus( | 125 Status status = LevelDBStatusToStatus( |
124 leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db)); | 126 leveldb::DB::Open(options, path_.AsUTF8Unsafe(), &db)); |
125 if (status != STATUS_OK) | 127 if (status != STATUS_OK) |
126 return status; | 128 return status; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 batch.Delete(iter->key()); | 368 batch.Delete(iter->key()); |
367 } | 369 } |
368 | 370 |
369 if (deleted_notification_set->empty()) | 371 if (deleted_notification_set->empty()) |
370 return STATUS_OK; | 372 return STATUS_OK; |
371 | 373 |
372 return LevelDBStatusToStatus(db_->Write(leveldb::WriteOptions(), &batch)); | 374 return LevelDBStatusToStatus(db_->Write(leveldb::WriteOptions(), &batch)); |
373 } | 375 } |
374 | 376 |
375 } // namespace content | 377 } // namespace content |
OLD | NEW |