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

Side by Side Diff: chrome/browser/extensions/settings/settings_leveldb_storage.cc

Issue 9284013: Extension Storage API: expose storage quota information to extensions, via: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: with use-after-free fixed Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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/settings/settings_leveldb_storage.h" 5 #include "chrome/browser/extensions/settings/settings_leveldb_storage.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (IsEmpty()) { 88 if (IsEmpty()) {
89 // Close |db_| now to release any lock on the directory. 89 // Close |db_| now to release any lock on the directory.
90 db_.reset(); 90 db_.reset();
91 if (!file_util::Delete(db_path_, true)) { 91 if (!file_util::Delete(db_path_, true)) {
92 LOG(WARNING) << "Failed to delete extension settings directory " << 92 LOG(WARNING) << "Failed to delete extension settings directory " <<
93 db_path_.value(); 93 db_path_.value();
94 } 94 }
95 } 95 }
96 } 96 }
97 97
98 size_t SettingsLeveldbStorage::GetBytesInUse(const std::string& key) {
99 // Let SettingsStorageQuotaEnforcer implement this.
100 NOTREACHED() << "Not implemented";
101 return 0;
102 }
103
104 size_t SettingsLeveldbStorage::GetBytesInUse(
105 const std::vector<std::string>& keys) {
106 // Let SettingsStorageQuotaEnforcer implement this.
107 NOTREACHED() << "Not implemented";
108 return 0;
109 }
110
111 size_t SettingsLeveldbStorage::GetBytesInUse() {
112 // Let SettingsStorageQuotaEnforcer implement this.
113 NOTREACHED() << "Not implemented";
114 return 0;
115 }
116
98 SettingsStorage::ReadResult SettingsLeveldbStorage::Get( 117 SettingsStorage::ReadResult SettingsLeveldbStorage::Get(
99 const std::string& key) { 118 const std::string& key) {
100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
101 scoped_ptr<Value> setting; 120 scoped_ptr<Value> setting;
102 if (!ReadFromDb(leveldb::ReadOptions(), key, &setting)) { 121 if (!ReadFromDb(leveldb::ReadOptions(), key, &setting)) {
103 return ReadResult(kGenericOnFailureMessage); 122 return ReadResult(kGenericOnFailureMessage);
104 } 123 }
105 DictionaryValue* settings = new DictionaryValue(); 124 DictionaryValue* settings = new DictionaryValue();
106 if (setting.get()) { 125 if (setting.get()) {
107 settings->SetWithoutPathExpansion(key, setting.release()); 126 settings->SetWithoutPathExpansion(key, setting.release());
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 it->SeekToFirst(); 337 it->SeekToFirst();
319 bool is_empty = !it->Valid(); 338 bool is_empty = !it->Valid();
320 if (!it->status().ok()) { 339 if (!it->status().ok()) {
321 LOG(ERROR) << "Checking DB emptiness failed: " << it->status().ToString(); 340 LOG(ERROR) << "Checking DB emptiness failed: " << it->status().ToString();
322 return false; 341 return false;
323 } 342 }
324 return is_empty; 343 return is_empty;
325 } 344 }
326 345
327 } // namespace extensions 346 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698