summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
authorchron@chromium.org <chron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 00:13:47 +0000
committerchron@chromium.org <chron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 00:13:47 +0000
commit551d976c7518976334d2bb2dfe978c7b28678172 (patch)
treea9e81bb49a23cd51368e56aec0efbf2e37b2dfa0 /chrome/browser/sync
parent3ed42e3fedfb159ee0fc81ca01daa6c158156bd3 (diff)
downloadchromium_src-551d976c7518976334d2bb2dfe978c7b28678172.zip
chromium_src-551d976c7518976334d2bb2dfe978c7b28678172.tar.gz
chromium_src-551d976c7518976334d2bb2dfe978c7b28678172.tar.bz2
Remove pthreads from syncable.
Remove unused kernel scoped unlock. BUG=19895 TEST=Existing unit tests Review URL: http://codereview.chromium.org/246097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r--chrome/browser/sync/syncable/syncable.cc24
-rw-r--r--chrome/browser/sync/syncable/syncable.h20
2 files changed, 10 insertions, 34 deletions
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index e8373a88..3f0c65b 100644
--- a/chrome/browser/sync/syncable/syncable.cc
+++ b/chrome/browser/sync/syncable/syncable.cc
@@ -202,7 +202,6 @@ Directory::Kernel::Kernel(const PathString& db_path,
next_metahandle(info.max_metahandle + 1),
next_id(info.kernel_info.next_id) {
info_status_ = Directory::KERNEL_SHARE_INFO_VALID;
- CHECK(0 == pthread_mutex_init(&mutex, NULL));
}
inline void DeleteEntry(EntryKernel* kernel) {
@@ -222,7 +221,6 @@ Directory::Kernel::~Kernel() {
CHECK(0 == refcount);
delete channel;
delete changes_channel;
- CHECK(0 == pthread_mutex_destroy(&mutex));
delete unsynced_metahandles;
delete unapplied_update_metahandles;
delete extended_attributes;
@@ -764,7 +762,9 @@ void Directory::TakeSnapshotForSaveChanges(SaveChangesSnapshot* snapshot) {
bool Directory::SaveChanges() {
bool success = false;
DCHECK(store_);
- PThreadScopedLock<PThreadMutex> lock(&kernel_->save_changes_mutex);
+
+ AutoLock(kernel_->save_changes_mutex);
+
// Snapshot and save.
SaveChangesSnapshot snapshot;
TakeSnapshotForSaveChanges(&snapshot);
@@ -1104,22 +1104,9 @@ void Directory::CheckTreeInvariants(syncable::BaseTransaction* trans,
// ScopedKernelLocks
ScopedKernelLock::ScopedKernelLock(const Directory* dir)
- : dir_(const_cast<Directory*>(dir)) {
+ : dir_(const_cast<Directory*>(dir)), scoped_lock_(dir_->kernel_->mutex) {
// Swap out the dbhandle to enforce the "No IO while holding kernel
// lock" rule.
- // HA!! Yeah right. What about your pre-cached queries :P
- pthread_mutex_lock(&dir->kernel_->mutex);
-}
-ScopedKernelLock::~ScopedKernelLock() {
- pthread_mutex_unlock(&dir_->kernel_->mutex);
-}
-
-ScopedKernelUnlock::ScopedKernelUnlock(ScopedKernelLock* lock)
- : lock_(lock) {
- pthread_mutex_unlock(&lock->dir_->kernel_->mutex);
-}
-ScopedKernelUnlock::~ScopedKernelUnlock() {
- pthread_mutex_lock(&lock_->dir_->kernel_->mutex);
}
///////////////////////////////////////////////////////////////////////////
@@ -1167,7 +1154,7 @@ void BaseTransaction::UnlockAndLog(OriginalEntries* originals_arg) {
return;
}
- dirkernel_->changes_channel_mutex.Lock();
+ AutoLock(dirkernel_->changes_channel_mutex);
// Tell listeners to calculate changes while we still have the mutex.
DirectoryChangeEvent event = { DirectoryChangeEvent::CALCULATE_CHANGES,
originals.get(), this, writer_ };
@@ -1179,7 +1166,6 @@ void BaseTransaction::UnlockAndLog(OriginalEntries* originals_arg) {
{ DirectoryChangeEvent::TRANSACTION_COMPLETE,
NULL, NULL, INVALID };
dirkernel_->changes_channel->NotifyListeners(complete_event);
- dirkernel_->changes_channel_mutex.Unlock();
}
ReadTransaction::ReadTransaction(Directory* directory, const char* file,
diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h
index 9af42f2..7ab804e 100644
--- a/chrome/browser/sync/syncable/syncable.h
+++ b/chrome/browser/sync/syncable/syncable.h
@@ -23,11 +23,9 @@
#include "chrome/browser/sync/syncable/path_name_cmp.h"
#include "chrome/browser/sync/syncable/syncable_id.h"
#include "chrome/browser/sync/util/compat_file.h"
-#include "chrome/browser/sync/util/compat_pthread.h"
#include "chrome/browser/sync/util/dbgq.h"
#include "chrome/browser/sync/util/event_sys.h"
#include "chrome/browser/sync/util/path_helpers.h"
-#include "chrome/browser/sync/util/pthread_helpers.h"
#include "chrome/browser/sync/util/row_iterator.h"
#include "chrome/browser/sync/util/sync_types.h"
@@ -810,7 +808,6 @@ struct ExtendedAttributeValue {
typedef std::map<ExtendedAttributeKey, ExtendedAttributeValue>
ExtendedAttributes;
-typedef PThreadScopedLock<PThreadMutex> ScopedTransactionLock;
typedef std::set<int64> MetahandleSet;
// A list of metahandles whose metadata should not be purged.
@@ -1127,7 +1124,7 @@ class Directory {
//
// Never hold the mutex and do anything with the database or any
// other buffered IO. Violating this rule will result in deadlock.
- pthread_mutex_t mutex; // TODO(chron): Swap this out for Chrome Lock
+ Lock mutex;
MetahandlesIndex* metahandles_index; // Entries indexed by metahandle
IdsIndex* ids_index; // Entries indexed by id
ParentIdAndNamesIndex* parent_id_and_names_index;
@@ -1150,7 +1147,7 @@ class Directory {
// while holding the transaction mutex and released after
// releasing the transaction mutex.
ChangesChannel* const changes_channel;
- PThreadMutex changes_channel_mutex;
+ Lock changes_channel_mutex;
KernelShareInfoStatus info_status_;
// These 5 members are backed in the share_info table, and
// their state is marked by the flag above.
@@ -1167,7 +1164,7 @@ class Directory {
// It doesn't make sense for two threads to run SaveChanges at the same
// time; this mutex protects that activity.
- PThreadMutex save_changes_mutex;
+ Lock save_changes_mutex;
// The next metahandle and id are protected by kernel mutex.
int64 next_metahandle;
@@ -1186,20 +1183,13 @@ class Directory {
class ScopedKernelLock {
public:
explicit ScopedKernelLock(const Directory*);
- ~ScopedKernelLock();
+ ~ScopedKernelLock() {}
+ AutoLock scoped_lock_;
Directory* const dir_;
DISALLOW_COPY_AND_ASSIGN(ScopedKernelLock);
};
-class ScopedKernelUnlock {
- public:
- explicit ScopedKernelUnlock(ScopedKernelLock* lock);
- ~ScopedKernelUnlock();
- ScopedKernelLock* const lock_;
- DISALLOW_COPY_AND_ASSIGN(ScopedKernelUnlock);
-};
-
// Transactions are now processed FIFO (+overlapping reads).
class BaseTransaction {
friend class Entry;