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

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

Issue 8366030: Introduce the plumbing necessary to report Unrecoverable error from model safe workers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For a high level review. Created 9 years, 2 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 namespace sync_api { 46 namespace sync_api {
47 class ReadTransaction; 47 class ReadTransaction;
48 class WriteNode; 48 class WriteNode;
49 class ReadNode; 49 class ReadNode;
50 } // sync_api 50 } // sync_api
51 51
52 namespace syncable { 52 namespace syncable {
53 class DirectoryChangeDelegate; 53 class DirectoryChangeDelegate;
54 class TransactionObserver; 54 class TransactionObserver;
55 class Entry; 55 class Entry;
56
57 std::ostream& operator<<(std::ostream& s, const Entry& e); 56 std::ostream& operator<<(std::ostream& s, const Entry& e);
58 57
59 class DirectoryBackingStore; 58 class DirectoryBackingStore;
60 59
61 static const int64 kInvalidMetaHandle = 0; 60 static const int64 kInvalidMetaHandle = 0;
62 61
63 // Things you need to update if you change any of the fields below: 62 // Things you need to update if you change any of the fields below:
64 // - EntryKernel struct in syncable.h (this file) 63 // - EntryKernel struct in syncable.h (this file)
65 // - syncable_columns.h 64 // - syncable_columns.h
66 // - syncable_enum_conversions{.h,.cc,_unittest.cc} 65 // - syncable_enum_conversions{.h,.cc,_unittest.cc}
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 866
868 // Unique to each account / client pair. 867 // Unique to each account / client pair.
869 std::string cache_guid() const; 868 std::string cache_guid() const;
870 869
871 // These are backed by a thread-safe observer list, and so can be 870 // These are backed by a thread-safe observer list, and so can be
872 // called on any thread, and events will be sent to the observer on 871 // called on any thread, and events will be sent to the observer on
873 // the same thread that it was added on. 872 // the same thread that it was added on.
874 void AddTransactionObserver(TransactionObserver* observer); 873 void AddTransactionObserver(TransactionObserver* observer);
875 void RemoveTransactionObserver(TransactionObserver* observer); 874 void RemoveTransactionObserver(TransactionObserver* observer);
876 875
876 void set_unrecoverable_error();
877 bool unrecoverable_error() const;
878
877 protected: // for friends, mainly used by Entry constructors 879 protected: // for friends, mainly used by Entry constructors
878 virtual EntryKernel* GetEntryByHandle(int64 handle); 880 virtual EntryKernel* GetEntryByHandle(int64 handle);
879 virtual EntryKernel* GetEntryByHandle(int64 metahandle, 881 virtual EntryKernel* GetEntryByHandle(int64 metahandle,
880 ScopedKernelLock* lock); 882 ScopedKernelLock* lock);
881 virtual EntryKernel* GetEntryById(const Id& id); 883 virtual EntryKernel* GetEntryById(const Id& id);
882 EntryKernel* GetEntryByServerTag(const std::string& tag); 884 EntryKernel* GetEntryByServerTag(const std::string& tag);
883 virtual EntryKernel* GetEntryByClientTag(const std::string& tag); 885 virtual EntryKernel* GetEntryByClientTag(const std::string& tag);
884 EntryKernel* GetRootEntry(); 886 EntryKernel* GetRootEntry();
885 bool ReindexId(EntryKernel* const entry, const Id& new_id); 887 bool ReindexId(EntryKernel* const entry, const Id& new_id);
886 void ReindexParentId(EntryKernel* const entry, const Id& new_parent_id); 888 void ReindexParentId(EntryKernel* const entry, const Id& new_parent_id);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 const Id& parent_id); 1147 const Id& parent_id);
1146 1148
1147 // Append the handles of the children of |parent_id| to |result|. 1149 // Append the handles of the children of |parent_id| to |result|.
1148 void AppendChildHandles( 1150 void AppendChildHandles(
1149 const ScopedKernelLock& lock, 1151 const ScopedKernelLock& lock,
1150 const Id& parent_id, Directory::ChildHandles* result); 1152 const Id& parent_id, Directory::ChildHandles* result);
1151 1153
1152 Kernel* kernel_; 1154 Kernel* kernel_;
1153 1155
1154 DirectoryBackingStore* store_; 1156 DirectoryBackingStore* store_;
1157
1158 // Keep a copy to check before performing some shutdown operations.
1159 // Otherwise if the store is corrupted and we perform those operations
1160 // anyway(as part of sync shutdown) then we will crash there.
1161 bool unrecoverable_error_;
1155 }; 1162 };
1156 1163
1157 class ScopedKernelLock { 1164 class ScopedKernelLock {
1158 public: 1165 public:
1159 explicit ScopedKernelLock(const Directory*); 1166 explicit ScopedKernelLock(const Directory*);
1160 ~ScopedKernelLock() {} 1167 ~ScopedKernelLock() {}
1161 1168
1162 base::AutoLock scoped_lock_; 1169 base::AutoLock scoped_lock_;
1163 Directory* const dir_; 1170 Directory* const dir_;
1164 DISALLOW_COPY_AND_ASSIGN(ScopedKernelLock); 1171 DISALLOW_COPY_AND_ASSIGN(ScopedKernelLock);
1165 }; 1172 };
1166 1173
1167 // Transactions are now processed FIFO with a straight lock 1174 // Transactions are now processed FIFO with a straight lock
1168 class BaseTransaction { 1175 class BaseTransaction {
1169 friend class Entry; 1176 friend class Entry;
1170 public: 1177 public:
1171 inline Directory* directory() const { return directory_; } 1178 inline Directory* directory() const { return directory_; }
1172 inline Id root_id() const { return Id(); } 1179 inline Id root_id() const { return Id(); }
1173 1180
1181 void set_unrecoverable_error();
1182
1174 virtual ~BaseTransaction(); 1183 virtual ~BaseTransaction();
1175 1184
1176 protected: 1185 protected:
1177 BaseTransaction(const tracked_objects::Location& from_here, 1186 BaseTransaction(const tracked_objects::Location& from_here,
1178 const char* name, 1187 const char* name,
1179 WriterTag writer, 1188 WriterTag writer,
1180 Directory* directory); 1189 Directory* directory);
1181 1190
1182 void Lock(); 1191 void Lock();
1183 void Unlock(); 1192 void Unlock();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); 1256 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid);
1248 1257
1249 // This function sets only the flags needed to get this entry to sync. 1258 // This function sets only the flags needed to get this entry to sync.
1250 void MarkForSyncing(syncable::MutableEntry* e); 1259 void MarkForSyncing(syncable::MutableEntry* e);
1251 1260
1252 } // namespace syncable 1261 } // namespace syncable
1253 1262
1254 std::ostream& operator <<(std::ostream&, const syncable::Blob&); 1263 std::ostream& operator <<(std::ostream&, const syncable::Blob&);
1255 1264
1256 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 1265 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698