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

Unified Diff: chrome/browser/sync/syncable/syncable.h

Issue 8586014: [Sync] Replace uses of ObserverListThreadSafe with WeakHandles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 9 years, 1 month 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/sync/syncable/directory_manager.cc ('k') | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/syncable/syncable.h
diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h
index 0f6ecee5d6f9e3625d7ca40bdd2207b2b21252f3..54fe4c031c55941ff3617b9d784f615e9ffac940 100644
--- a/chrome/browser/sync/syncable/syncable.h
+++ b/chrome/browser/sync/syncable/syncable.h
@@ -24,7 +24,6 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/observer_list_threadsafe.h"
#include "base/synchronization/lock.h"
#include "base/time.h"
#include "chrome/browser/sync/protocol/sync.pb.h"
@@ -35,6 +34,7 @@
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/util/immutable.h"
#include "chrome/browser/sync/util/time.h"
+#include "chrome/browser/sync/util/weak_handle.h"
namespace base {
class DictionaryValue;
@@ -821,11 +821,14 @@ class Directory {
// Does not take ownership of |delegate|, which must not be NULL.
// Starts sending events to |delegate| if the returned result is
// OPENED. Note that events to |delegate| may be sent from *any*
- // thread.
+ // thread. |transaction_observer| must be initialized.
DirOpenResult Open(const FilePath& file_path, const std::string& name,
- DirectoryChangeDelegate* delegate);
+ DirectoryChangeDelegate* delegate,
+ const browser_sync::WeakHandle<TransactionObserver>&
+ transaction_observer);
- // Stops sending events to the delegate.
+ // Stops sending events to the delegate and the transaction
+ // observer.
void Close();
int64 NextMetahandle();
@@ -866,12 +869,6 @@ class Directory {
// Unique to each account / client pair.
std::string cache_guid() const;
- // These are backed by a thread-safe observer list, and so can be
- // called on any thread, and events will be sent to the observer on
- // the same thread that it was added on.
- void AddTransactionObserver(TransactionObserver* observer);
- void RemoveTransactionObserver(TransactionObserver* observer);
-
protected: // for friends, mainly used by Entry constructors
virtual EntryKernel* GetEntryByHandle(int64 handle);
virtual EntryKernel* GetEntryByHandle(int64 metahandle,
@@ -900,8 +897,11 @@ class Directory {
// before calling.
EntryKernel* GetEntryById(const Id& id, ScopedKernelLock* const lock);
- DirOpenResult OpenImpl(const FilePath& file_path, const std::string& name,
- DirectoryChangeDelegate* delegate);
+ DirOpenResult OpenImpl(
+ const FilePath& file_path, const std::string& name,
+ DirectoryChangeDelegate* delegate,
+ const browser_sync::WeakHandle<TransactionObserver>&
+ transaction_observer);
template <class T> void TestAndSet(T* kernel_data, const T* data_to_set);
@@ -1049,14 +1049,22 @@ class Directory {
typedef Index<ClientTagIndexer>::Set ClientTagIndex;
protected:
- // Used by tests.
- void InitKernel(const std::string& name, DirectoryChangeDelegate* delegate);
+ // Used by tests. |delegate| must not be NULL.
+ // |transaction_observer| must be initialized.
+ void InitKernelForTest(
+ const std::string& name,
+ DirectoryChangeDelegate* delegate,
+ const browser_sync::WeakHandle<TransactionObserver>&
+ transaction_observer);
private:
struct Kernel {
- // |delegate| can be NULL.
+ // |delegate| must not be NULL. |transaction_observer| must be
+ // initialized.
Kernel(const FilePath& db_path, const std::string& name,
- const KernelLoadInfo& info, DirectoryChangeDelegate* delegate);
+ const KernelLoadInfo& info, DirectoryChangeDelegate* delegate,
+ const browser_sync::WeakHandle<TransactionObserver>&
+ transaction_observer);
~Kernel();
@@ -1125,11 +1133,11 @@ class Directory {
// The next metahandle is protected by kernel mutex.
int64 next_metahandle;
- // The delegate for directory change events. Can be NULL.
+ // The delegate for directory change events. Must not be NULL.
DirectoryChangeDelegate* const delegate;
- // The transaction observers.
- scoped_refptr<ObserverListThreadSafe<TransactionObserver> > observers;
+ // The transaction observer.
+ const browser_sync::WeakHandle<TransactionObserver> transaction_observer;
};
// Helper method used to do searches on |parent_id_child_index|.
« no previous file with comments | « chrome/browser/sync/syncable/directory_manager.cc ('k') | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698