OLD | NEW |
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 #include "chrome/browser/extensions/app_notification_storage.h" | 5 #include "chrome/browser/extensions/app_notification_storage.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 124 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
125 CHECK(result); | 125 CHECK(result); |
126 if (!OpenDbIfNeeded(false)) | 126 if (!OpenDbIfNeeded(false)) |
127 return false; | 127 return false; |
128 if (!db_.get()) | 128 if (!db_.get()) |
129 return true; | 129 return true; |
130 | 130 |
131 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(read_options_)); | 131 scoped_ptr<leveldb::Iterator> iter(db_->NewIterator(read_options_)); |
132 for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { | 132 for (iter->SeekToFirst(); iter->Valid(); iter->Next()) { |
133 std::string key = iter->key().ToString(); | 133 std::string key = iter->key().ToString(); |
134 if (Extension::IdIsValid(key)) | 134 if (extensions::Extension::IdIsValid(key)) |
135 result->insert(key); | 135 result->insert(key); |
136 } | 136 } |
137 | 137 |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
141 bool LevelDbAppNotificationStorage::Get(const std::string& extension_id, | 141 bool LevelDbAppNotificationStorage::Get(const std::string& extension_id, |
142 AppNotificationList* result) { | 142 AppNotificationList* result) { |
143 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 143 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
144 CHECK(result); | 144 CHECK(result); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 options.create_if_missing = true; | 219 options.create_if_missing = true; |
220 leveldb::DB* db = NULL; | 220 leveldb::DB* db = NULL; |
221 leveldb::Status status = leveldb::DB::Open(options, os_path, &db); | 221 leveldb::Status status = leveldb::DB::Open(options, os_path, &db); |
222 if (!status.ok()) { | 222 if (!status.ok()) { |
223 LogLevelDbError(FROM_HERE, status); | 223 LogLevelDbError(FROM_HERE, status); |
224 return false; | 224 return false; |
225 } | 225 } |
226 db_.reset(db); | 226 db_.reset(db); |
227 return true; | 227 return true; |
228 } | 228 } |
OLD | NEW |