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

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

Issue 10407013: Minor GDataDB fixes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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_db_unittest.cc ('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
===================================================================
--- chrome/browser/chromeos/gdata/gdata_leveldb.cc (revision 137975)
+++ chrome/browser/chromeos/gdata/gdata_leveldb.cc (working copy)
@@ -7,6 +7,7 @@
#include <string>
#include "base/logging.h"
+#include "base/threading/thread_restrictions.h"
#include "chrome/browser/chromeos/gdata/gdata_files.h"
#include "leveldb/write_batch.h"
@@ -52,6 +53,8 @@
}
void GDataLevelDB::Init(const FilePath& db_path) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
leveldb::DB* level_db = NULL;
leveldb::Options options;
options.create_if_missing = true;
@@ -65,6 +68,8 @@
}
GDataDB::Status GDataLevelDB::Put(const GDataEntry& entry) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
// Write the serialized proto.
std::string serialized_proto;
entry.SerializeToString(&serialized_proto);
@@ -87,6 +92,8 @@
GDataDB::Status GDataLevelDB::DeleteByResourceId(
const std::string& resource_id) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
scoped_ptr<GDataEntry> entry;
Status status = GetByResourceId(resource_id, &entry);
if (status == DB_KEY_NOT_FOUND)
@@ -107,6 +114,8 @@
GDataDB::Status GDataLevelDB::DeleteByPath(
const FilePath& path) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
std::string resource_id;
const Status status = ResourceIdForPath(path, &resource_id);
if (status != DB_OK)
@@ -116,6 +125,8 @@
GDataDB::Status GDataLevelDB::GetByResourceId(const std::string& resource_id,
scoped_ptr<GDataEntry>* entry) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
entry->reset();
std::string serialized_proto;
const std::string resource_id_key = ResourceIdToKey(resource_id);
@@ -136,6 +147,8 @@
GDataDB::Status GDataLevelDB::GetByPath(const FilePath& path,
scoped_ptr<GDataEntry>* entry) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
entry->reset();
std::string resource_id;
const Status status = ResourceIdForPath(path, &resource_id);
@@ -146,6 +159,8 @@
GDataDB::Status GDataLevelDB::ResourceIdForPath(const FilePath& path,
std::string* resource_id) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
const std::string path_key = PathToKey(path);
const leveldb::Status db_status = level_db_->Get(
leveldb::ReadOptions(), path_key, resource_id);
@@ -167,6 +182,8 @@
: level_db_iter_(level_db_iter.Pass()),
db_(db),
path_(path) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
const std::string path_key = PathToKey(path);
level_db_iter_->Seek(leveldb::Slice(path_key));
}
@@ -176,6 +193,8 @@
bool GDataLevelDBIter::GetNext(std::string* path,
scoped_ptr<GDataEntry>* entry) {
+ base::ThreadRestrictions::AssertIOAllowed();
+
DCHECK(path);
DCHECK(entry);
path->clear();
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_db_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698