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

Unified Diff: chrome/browser/chromeos/gdata/gdata_leveldb.cc

Issue 10701118: gdata: Fix a bug in GDataLevelDB where errors are not handled right (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_leveldb.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_leveldb.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_leveldb.cc b/chrome/browser/chromeos/gdata/gdata_leveldb.cc
index 8ea19c67722c2dff7d3c0407ac35b6dd3a411a6a..5197928db9643098d1c7e5f8ad5e79efd37d8599 100644
--- a/chrome/browser/chromeos/gdata/gdata_leveldb.cc
+++ b/chrome/browser/chromeos/gdata/gdata_leveldb.cc
@@ -139,8 +139,7 @@ GDataDB::Status GDataLevelDB::GetByResourceId(const std::string& resource_id,
if (db_status.ok()) {
DCHECK(!serialized_proto.empty());
*entry = GDataEntry::FromProtoString(serialized_proto);
- DCHECK(entry->get());
- return DB_OK;
+ return entry->get() ? DB_OK : DB_CORRUPTION;
}
return GetStatus(db_status);
}
@@ -176,6 +175,18 @@ scoped_ptr<GDataDBIter> GDataLevelDB::CreateIterator(const FilePath& path) {
path));
}
+GDataDB::Status GDataLevelDB::PutRawForTesting(
+ const std::string& resource_id,
+ const std::string& raw_value) {
+ const std::string resource_id_key = ResourceIdToKey(resource_id);
+ leveldb::Status db_status = level_db_->Put(
+ leveldb::WriteOptions(),
+ leveldb::Slice(resource_id_key),
+ leveldb::Slice(raw_value));
+
+ return GetStatus(db_status);
+}
+
GDataLevelDBIter::GDataLevelDBIter(scoped_ptr<leveldb::Iterator> level_db_iter,
GDataDB* db,
const FilePath& path)
@@ -211,7 +222,8 @@ bool GDataLevelDBIter::GetNext(std::string* path,
GDataDB::Status status =
db_->GetByResourceId(level_db_iter_->value().ToString(), entry);
- DCHECK_EQ(GDataDB::DB_OK, status);
+ if (status != GDataDB::DB_OK)
+ return false;
key_slice.remove_prefix(sizeof(kPathPrefix) - 1);
path->assign(key_slice.ToString());
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_leveldb.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698