summaryrefslogtreecommitdiffstats
path: root/components/dom_distiller
diff options
context:
space:
mode:
authorcjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-13 21:11:54 +0000
committercjhopman@chromium.org <cjhopman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-13 21:11:54 +0000
commitfe1e675b8dc5e6fed7082f23c08fd11fda376825 (patch)
tree384993073b106ec4dd0e419163e773bf5b9d0c4c /components/dom_distiller
parentf016174aae0c998630521484063ea5c8808e1203 (diff)
downloadchromium_src-fe1e675b8dc5e6fed7082f23c08fd11fda376825.zip
chromium_src-fe1e675b8dc5e6fed7082f23c08fd11fda376825.tar.gz
chromium_src-fe1e675b8dc5e6fed7082f23c08fd11fda376825.tar.bz2
Make thread checking in DomDistillerDatabase::LevelDB more flexible
This replaces the ThreadChecker with a ThreadCollisionWarner. The LevelDB does not actually need to be run on a single thread, instead it just needs its function calls to be sequenced in some way. Review URL: https://codereview.chromium.org/70643002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/dom_distiller')
-rw-r--r--components/dom_distiller/core/dom_distiller_database.cc12
-rw-r--r--components/dom_distiller/core/dom_distiller_database.h3
2 files changed, 7 insertions, 8 deletions
diff --git a/components/dom_distiller/core/dom_distiller_database.cc b/components/dom_distiller/core/dom_distiller_database.cc
index cda79fb..5cd4c128 100644
--- a/components/dom_distiller/core/dom_distiller_database.cc
+++ b/components/dom_distiller/core/dom_distiller_database.cc
@@ -23,16 +23,14 @@ using base::SequencedTaskRunner;
namespace dom_distiller {
-DomDistillerDatabase::LevelDB::LevelDB() {
- thread_checker_.DetachFromThread();
-}
+DomDistillerDatabase::LevelDB::LevelDB() {}
DomDistillerDatabase::LevelDB::~LevelDB() {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DFAKE_SCOPED_LOCK(thread_checker_);
}
bool DomDistillerDatabase::LevelDB::Init(const base::FilePath& database_dir) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DFAKE_SCOPED_LOCK(thread_checker_);
leveldb::Options options;
options.create_if_missing = true;
@@ -59,7 +57,7 @@ bool DomDistillerDatabase::LevelDB::Init(const base::FilePath& database_dir) {
}
bool DomDistillerDatabase::LevelDB::Save(const EntryVector& entries) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DFAKE_SCOPED_LOCK(thread_checker_);
leveldb::WriteBatch updates;
for (EntryVector::const_iterator it = entries.begin(); it != entries.end();
@@ -80,7 +78,7 @@ bool DomDistillerDatabase::LevelDB::Save(const EntryVector& entries) {
}
bool DomDistillerDatabase::LevelDB::Load(EntryVector* entries) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DFAKE_SCOPED_LOCK(thread_checker_);
leveldb::ReadOptions options;
scoped_ptr<leveldb::Iterator> db_iterator(db_->NewIterator(options));
diff --git a/components/dom_distiller/core/dom_distiller_database.h b/components/dom_distiller/core/dom_distiller_database.h
index d50568b..731c2a8 100644
--- a/components/dom_distiller/core/dom_distiller_database.h
+++ b/components/dom_distiller/core/dom_distiller_database.h
@@ -15,6 +15,7 @@
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
+#include "base/threading/thread_collision_warner.h"
#include "components/dom_distiller/core/article_entry.h"
namespace base {
@@ -81,7 +82,7 @@ class DomDistillerDatabase
virtual bool Load(EntryVector* entries) OVERRIDE;
private:
- base::ThreadChecker thread_checker_;
+ DFAKE_MUTEX(thread_checker_);
scoped_ptr<leveldb::DB> db_;
};