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

Side by Side Diff: chrome/browser/sync/syncable/syncable.h

Issue 7046067: [Sync] Fix use of ObserverList by multiple threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 5 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <bitset> 10 #include <bitset>
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 989
990 struct Kernel { 990 struct Kernel {
991 Kernel(const FilePath& db_path, const std::string& name, 991 Kernel(const FilePath& db_path, const std::string& name,
992 const KernelLoadInfo& info); 992 const KernelLoadInfo& info);
993 993
994 ~Kernel(); 994 ~Kernel();
995 995
996 void AddRef(); // For convenience. 996 void AddRef(); // For convenience.
997 void Release(); 997 void Release();
998 998
999 void AddChangeListener(DirectoryChangeListener* listener);
1000 void RemoveChangeListener(DirectoryChangeListener* listener);
1001
1002 void CopyChangeListeners(
1003 ObserverList<DirectoryChangeListener>* change_listeners);
1004
999 FilePath const db_path; 1005 FilePath const db_path;
1000 // TODO(timsteele): audit use of the member and remove if possible 1006 // TODO(timsteele): audit use of the member and remove if possible
1001 volatile base::subtle::AtomicWord refcount; 1007 volatile base::subtle::AtomicWord refcount;
1002 1008
1003 // Implements ReadTransaction / WriteTransaction using a simple lock. 1009 // Implements ReadTransaction / WriteTransaction using a simple lock.
1004 base::Lock transaction_mutex; 1010 base::Lock transaction_mutex;
1005 1011
1006 // The name of this directory. 1012 // The name of this directory.
1007 std::string const name; 1013 std::string const name;
1008 1014
(...skipping 22 matching lines...) Expand all
1031 // necessarily). Dirtyness is confirmed in TakeSnapshotForSaveChanges(). 1037 // necessarily). Dirtyness is confirmed in TakeSnapshotForSaveChanges().
1032 MetahandleSet* const dirty_metahandles; 1038 MetahandleSet* const dirty_metahandles;
1033 1039
1034 // When a purge takes place, we remove items from all our indices and stash 1040 // When a purge takes place, we remove items from all our indices and stash
1035 // them in here so that SaveChanges can persist their permanent deletion. 1041 // them in here so that SaveChanges can persist their permanent deletion.
1036 MetahandleSet* const metahandles_to_purge; 1042 MetahandleSet* const metahandles_to_purge;
1037 1043
1038 // TODO(ncarter): Figure out what the hell this is, and comment it. 1044 // TODO(ncarter): Figure out what the hell this is, and comment it.
1039 Channel* const channel; 1045 Channel* const channel;
1040 1046
1041 // The listeners for directory change events, triggered when the
1042 // transaction is ending.
1043 ObserverList<DirectoryChangeListener> change_listeners_;
1044
1045 KernelShareInfoStatus info_status; 1047 KernelShareInfoStatus info_status;
1046 1048
1047 // These 3 members are backed in the share_info table, and 1049 // These 3 members are backed in the share_info table, and
1048 // their state is marked by the flag above. 1050 // their state is marked by the flag above.
1049 1051
1050 // A structure containing the Directory state that is written back into the 1052 // A structure containing the Directory state that is written back into the
1051 // database on SaveChanges. 1053 // database on SaveChanges.
1052 PersistedKernelInfo persisted_info; 1054 PersistedKernelInfo persisted_info;
1053 1055
1054 // A unique identifier for this account's cache db, used to generate 1056 // A unique identifier for this account's cache db, used to generate
1055 // unique server IDs. No need to lock, only written at init time. 1057 // unique server IDs. No need to lock, only written at init time.
1056 std::string cache_guid; 1058 std::string cache_guid;
1057 1059
1058 // It doesn't make sense for two threads to run SaveChanges at the same 1060 // It doesn't make sense for two threads to run SaveChanges at the same
1059 // time; this mutex protects that activity. 1061 // time; this mutex protects that activity.
1060 base::Lock save_changes_mutex; 1062 base::Lock save_changes_mutex;
1061 1063
1062 // The next metahandle is protected by kernel mutex. 1064 // The next metahandle is protected by kernel mutex.
1063 int64 next_metahandle; 1065 int64 next_metahandle;
1064 1066
1065 // Keep a history of recently flushed metahandles for debugging 1067 // Keep a history of recently flushed metahandles for debugging
1066 // purposes. Protected by the save_changes_mutex. 1068 // purposes. Protected by the save_changes_mutex.
1067 DebugQueue<int64, 1000> flushed_metahandles; 1069 DebugQueue<int64, 1000> flushed_metahandles;
1070
1071 private:
1072 // The listeners for directory change events, triggered when the
1073 // transaction is ending (and its lock).
1074 base::Lock change_listeners_lock_;
1075 ObserverList<DirectoryChangeListener> change_listeners_;
1068 }; 1076 };
1069 1077
1070 // Helper method used to do searches on |parent_id_child_index|. 1078 // Helper method used to do searches on |parent_id_child_index|.
1071 ParentIdChildIndex::iterator LocateInParentChildIndex( 1079 ParentIdChildIndex::iterator LocateInParentChildIndex(
1072 const ScopedKernelLock& lock, 1080 const ScopedKernelLock& lock,
1073 const Id& parent_id, 1081 const Id& parent_id,
1074 int64 position_in_parent, 1082 int64 position_in_parent,
1075 const Id& item_id_for_tiebreaking); 1083 const Id& item_id_for_tiebreaking);
1076 1084
1077 // Return an iterator to the beginning of the range of the children of 1085 // Return an iterator to the beginning of the range of the children of
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 1200
1193 // This is not a reset. It just sets the numeric fields which are not 1201 // This is not a reset. It just sets the numeric fields which are not
1194 // initialized by the constructor to zero. 1202 // initialized by the constructor to zero.
1195 void ZeroFields(EntryKernel* entry, int first_field); 1203 void ZeroFields(EntryKernel* entry, int first_field);
1196 1204
1197 } // namespace syncable 1205 } // namespace syncable
1198 1206
1199 std::ostream& operator <<(std::ostream&, const syncable::Blob&); 1207 std::ostream& operator <<(std::ostream&, const syncable::Blob&);
1200 1208
1201 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 1209 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698