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

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

Issue 8637006: [Sync] Make syncer commands avoid posting tasks on threads with no work to do (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head, fix windows compile Created 9 years 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 inline std::string& mutable_ref(StringField field) { 364 inline std::string& mutable_ref(StringField field) {
365 return string_fields[field - STRING_FIELDS_BEGIN]; 365 return string_fields[field - STRING_FIELDS_BEGIN];
366 } 366 }
367 inline sync_pb::EntitySpecifics& mutable_ref(ProtoField field) { 367 inline sync_pb::EntitySpecifics& mutable_ref(ProtoField field) {
368 return specifics_fields[field - PROTO_FIELDS_BEGIN]; 368 return specifics_fields[field - PROTO_FIELDS_BEGIN];
369 } 369 }
370 inline Id& mutable_ref(IdField field) { 370 inline Id& mutable_ref(IdField field) {
371 return id_fields[field - ID_FIELDS_BEGIN]; 371 return id_fields[field - ID_FIELDS_BEGIN];
372 } 372 }
373 373
374 syncable::ModelType GetServerModelType() const;
375
374 // Does a case in-sensitive search for a given string, which must be 376 // Does a case in-sensitive search for a given string, which must be
375 // lower case. 377 // lower case.
376 bool ContainsString(const std::string& lowercase_query) const; 378 bool ContainsString(const std::string& lowercase_query) const;
377 379
378 // Dumps all kernel info into a DictionaryValue and returns it. 380 // Dumps all kernel info into a DictionaryValue and returns it.
379 // Transfers ownership of the DictionaryValue to the caller. 381 // Transfers ownership of the DictionaryValue to the caller.
380 base::DictionaryValue* ToValue() const; 382 base::DictionaryValue* ToValue() const;
381 383
382 private: 384 private:
383 // Tracks whether this entry needs to be saved to the database. 385 // Tracks whether this entry needs to be saved to the database.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 inline explicit Entry(BaseTransaction* trans) 482 inline explicit Entry(BaseTransaction* trans)
481 : basetrans_(trans), 483 : basetrans_(trans),
482 kernel_(NULL) { } 484 kernel_(NULL) { }
483 485
484 protected: 486 protected:
485 BaseTransaction* const basetrans_; 487 BaseTransaction* const basetrans_;
486 488
487 EntryKernel* kernel_; 489 EntryKernel* kernel_;
488 490
489 private: 491 private:
490 // Like GetServerModelType() but without the DCHECKs.
491 ModelType GetServerModelTypeHelper() const;
492
493 DISALLOW_COPY_AND_ASSIGN(Entry); 492 DISALLOW_COPY_AND_ASSIGN(Entry);
494 }; 493 };
495 494
496 // A mutable meta entry. Changes get committed to the database when the 495 // A mutable meta entry. Changes get committed to the database when the
497 // WriteTransaction is destroyed. 496 // WriteTransaction is destroyed.
498 class MutableEntry : public Entry { 497 class MutableEntry : public Entry {
499 friend class WriteTransaction; 498 friend class WriteTransaction;
500 friend class Directory; 499 friend class Directory;
501 void Init(WriteTransaction* trans, const Id& parent_id, 500 void Init(WriteTransaction* trans, const Id& parent_id,
502 const std::string& name); 501 const std::string& name);
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 // Returns the number of entities with the unsynced bit set. 961 // Returns the number of entities with the unsynced bit set.
963 int64 unsynced_entity_count() const; 962 int64 unsynced_entity_count() const;
964 963
965 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and 964 // Get GetUnsyncedMetaHandles should only be called after SaveChanges and
966 // before any new entries have been created. The intention is that the 965 // before any new entries have been created. The intention is that the
967 // syncer should call it from its PerformSyncQueries member. 966 // syncer should call it from its PerformSyncQueries member.
968 typedef std::vector<int64> UnsyncedMetaHandles; 967 typedef std::vector<int64> UnsyncedMetaHandles;
969 void GetUnsyncedMetaHandles(BaseTransaction* trans, 968 void GetUnsyncedMetaHandles(BaseTransaction* trans,
970 UnsyncedMetaHandles* result); 969 UnsyncedMetaHandles* result);
971 970
972 // Get all the metahandles for unapplied updates 971 // Returns all server types with unapplied updates. A subset of
972 // those types can then be passed into
973 // GetUnappliedUpdateMetaHandles() below.
974 syncable::ModelTypeBitSet GetServerTypesWithUnappliedUpdates(
975 BaseTransaction* trans) const;
976
977 // Get all the metahandles for unapplied updates for a given set of
978 // server types.
973 typedef std::vector<int64> UnappliedUpdateMetaHandles; 979 typedef std::vector<int64> UnappliedUpdateMetaHandles;
974 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans, 980 void GetUnappliedUpdateMetaHandles(BaseTransaction* trans,
981 syncable::ModelTypeBitSet server_types,
975 UnappliedUpdateMetaHandles* result); 982 UnappliedUpdateMetaHandles* result);
976 983
977 // Checks tree metadata consistency. 984 // Checks tree metadata consistency.
978 // If full_scan is false, the function will avoid pulling any entries from the 985 // If full_scan is false, the function will avoid pulling any entries from the
979 // db and scan entries currently in ram. 986 // db and scan entries currently in ram.
980 // If full_scan is true, all entries will be pulled from the database. 987 // If full_scan is true, all entries will be pulled from the database.
981 // No return value, CHECKs will be triggered if we're given bad 988 // No return value, CHECKs will be triggered if we're given bad
982 // information. 989 // information.
983 void CheckTreeInvariants(syncable::BaseTransaction* trans, 990 void CheckTreeInvariants(syncable::BaseTransaction* trans,
984 bool full_scan); 991 bool full_scan);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 MetahandlesIndex* metahandles_index; 1103 MetahandlesIndex* metahandles_index;
1097 // Entries indexed by id 1104 // Entries indexed by id
1098 IdsIndex* ids_index; 1105 IdsIndex* ids_index;
1099 ParentIdChildIndex* parent_id_child_index; 1106 ParentIdChildIndex* parent_id_child_index;
1100 ClientTagIndex* client_tag_index; 1107 ClientTagIndex* client_tag_index;
1101 // So we don't have to create an EntryKernel every time we want to 1108 // So we don't have to create an EntryKernel every time we want to
1102 // look something up in an index. Needle in haystack metaphor. 1109 // look something up in an index. Needle in haystack metaphor.
1103 EntryKernel needle; 1110 EntryKernel needle;
1104 1111
1105 // 3 in-memory indices on bits used extremely frequently by the syncer. 1112 // 3 in-memory indices on bits used extremely frequently by the syncer.
1106 MetahandleSet* const unapplied_update_metahandles; 1113 // |unapplied_update_metahandles| is keyed by the server model type.
1114 MetahandleSet unapplied_update_metahandles[MODEL_TYPE_COUNT];
1107 MetahandleSet* const unsynced_metahandles; 1115 MetahandleSet* const unsynced_metahandles;
1108 // Contains metahandles that are most likely dirty (though not 1116 // Contains metahandles that are most likely dirty (though not
1109 // necessarily). Dirtyness is confirmed in TakeSnapshotForSaveChanges(). 1117 // necessarily). Dirtyness is confirmed in TakeSnapshotForSaveChanges().
1110 MetahandleSet* const dirty_metahandles; 1118 MetahandleSet* const dirty_metahandles;
1111 1119
1112 // When a purge takes place, we remove items from all our indices and stash 1120 // When a purge takes place, we remove items from all our indices and stash
1113 // them in here so that SaveChanges can persist their permanent deletion. 1121 // them in here so that SaveChanges can persist their permanent deletion.
1114 MetahandleSet* const metahandles_to_purge; 1122 MetahandleSet* const metahandles_to_purge;
1115 1123
1116 KernelShareInfoStatus info_status; 1124 KernelShareInfoStatus info_status;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid); 1281 bool IsLegalNewParent(BaseTransaction* trans, const Id& id, const Id& parentid);
1274 1282
1275 // This function sets only the flags needed to get this entry to sync. 1283 // This function sets only the flags needed to get this entry to sync.
1276 void MarkForSyncing(syncable::MutableEntry* e); 1284 void MarkForSyncing(syncable::MutableEntry* e);
1277 1285
1278 } // namespace syncable 1286 } // namespace syncable
1279 1287
1280 std::ostream& operator <<(std::ostream&, const syncable::Blob&); 1288 std::ostream& operator <<(std::ostream&, const syncable::Blob&);
1281 1289
1282 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_ 1290 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/sessions/sync_session_unittest.cc ('k') | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698