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

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: 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
Index: chrome/browser/sync/syncable/syncable.h
diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h
index 6c55613d11f90113f3869a172cee0511350b3cf7..79fa80535658e71960cd715612dfdc73c46d2556 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"
@@ -36,6 +35,7 @@
#include "chrome/browser/sync/util/dbgq.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;
@@ -822,11 +822,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();
@@ -867,12 +870,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,
@@ -901,8 +898,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);
@@ -1050,14 +1050,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();
@@ -1130,11 +1138,11 @@ class Directory {
// purposes. Protected by the save_changes_mutex.
DebugQueue<int64, 1000> flushed_metahandles;
- // 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|.

Powered by Google App Engine
This is Rietveld 408576698