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

Side by Side Diff: extensions/browser/value_store/lazy_leveldb.cc

Issue 2799543002: Avoid status strings on successful ValueStore status. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "extensions/browser/value_store/lazy_leveldb.h" 5 #include "extensions/browser/value_store/lazy_leveldb.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 status.code = ValueStore::OK; 246 status.code = ValueStore::OK;
247 status.message = kRestoredDuringOpen; 247 status.message = kRestoredDuringOpen;
248 } 248 }
249 } 249 }
250 250
251 return status; 251 return status;
252 } 252 }
253 253
254 ValueStore::Status LazyLevelDb::ToValueStoreError( 254 ValueStore::Status LazyLevelDb::ToValueStoreError(
255 const leveldb::Status& status) { 255 const leveldb::Status& status) {
256 if (status.ok())
257 return ValueStore::Status();
258
256 CHECK(!status.IsNotFound()); // not an error 259 CHECK(!status.IsNotFound()); // not an error
257 260
258 std::string message = status.ToString(); 261 std::string message = status.ToString();
259 // The message may contain |db_path_|, which may be considered sensitive 262 // The message may contain |db_path_|, which may be considered sensitive
260 // data, and those strings are passed to the extension, so strip it out. 263 // data, and those strings are passed to the extension, so strip it out.
261 base::ReplaceSubstringsAfterOffset(&message, 0u, db_path_.AsUTF8Unsafe(), 264 base::ReplaceSubstringsAfterOffset(&message, 0u, db_path_.AsUTF8Unsafe(),
262 "..."); 265 "...");
263 266
264 return ValueStore::Status(LevelDbToValueStoreStatusCode(status), message); 267 return ValueStore::Status(LevelDbToValueStoreStatusCode(status), message);
265 } 268 }
(...skipping 10 matching lines...) Expand all
276 279
277 ValueStore::Status LazyLevelDb::CreateIterator( 280 ValueStore::Status LazyLevelDb::CreateIterator(
278 const leveldb::ReadOptions& read_options, 281 const leveldb::ReadOptions& read_options,
279 std::unique_ptr<leveldb::Iterator>* iterator) { 282 std::unique_ptr<leveldb::Iterator>* iterator) {
280 ValueStore::Status status = EnsureDbIsOpen(); 283 ValueStore::Status status = EnsureDbIsOpen();
281 if (!status.ok()) 284 if (!status.ok())
282 return status; 285 return status;
283 *iterator = base::WrapUnique(db_->NewIterator(read_options)); 286 *iterator = base::WrapUnique(db_->NewIterator(read_options));
284 return ValueStore::Status(); 287 return ValueStore::Status();
285 } 288 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698