 Chromium Code Reviews
 Chromium Code Reviews Issue 14963002:
  sync: Report GetUpdate triggers to the server  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 14963002:
  sync: Report GetUpdate triggers to the server  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: sync/sessions/nudge_tracker.h | 
| diff --git a/sync/sessions/nudge_tracker.h b/sync/sessions/nudge_tracker.h | 
| index 0128ce096efa4075383b579b502f44eafcd75297..5e70014bd0856b4cea5bca2d1f9defbb8ec2038f 100644 | 
| --- a/sync/sessions/nudge_tracker.h | 
| +++ b/sync/sessions/nudge_tracker.h | 
| @@ -7,11 +7,14 @@ | 
| #ifndef SYNC_SESSIONS_NUDGE_TRACKER_H_ | 
| #define SYNC_SESSIONS_NUDGE_TRACKER_H_ | 
| -#include <vector> | 
| +#include <list> | 
| +#include <map> | 
| #include "base/compiler_specific.h" | 
| #include "sync/base/sync_export.h" | 
| -#include "sync/internal_api/public/sessions/sync_source_info.h" | 
| +#include "sync/internal_api/public/base/model_type.h" | 
| +#include "sync/internal_api/public/base/model_type_invalidation_map.h" | 
| +#include "sync/protocol/sync.pb.h" | 
| namespace syncer { | 
| namespace sessions { | 
| @@ -20,30 +23,102 @@ struct SyncSourceInfo; | 
| class SYNC_EXPORT_PRIVATE NudgeTracker { | 
| public: | 
| + static size_t kMaxPayloadsPerType; | 
| + | 
| NudgeTracker(); | 
| ~NudgeTracker(); | 
| - // Merges in the information from another nudge. | 
| - void CoalesceSources(const SyncSourceInfo& source); | 
| + // Returns true if there is a good reason for performing a sync cycle. | 
| + // This does not take into account whether or not this is a good *time* to | 
| + // perform a sync cycle; that's the scheduler's job. | 
| + bool SyncRequired(); | 
| 
tim (not reviewing)
2013/05/06 21:29:04
nit - IsSyncRequired()
 
rlarocque
2013/05/07 18:45:39
Done.
 | 
| + | 
| + // Tells this class that all required update fetching and committing has | 
| + // completed successfully. | 
| + void RecordSuccessfulSyncCycle(); | 
| + | 
| + // Takes note of a local change. | 
| + void RecordLocalChange(ModelTypeSet types); | 
| + | 
| + // Takes note of a locally issued request to refresh a data type. | 
| + void RecordLocalRefreshRequest(ModelTypeSet types); | 
| - // Returns true if there are no unserviced nudges. | 
| - bool IsEmpty(); | 
| + // Takes note of the receipt of an invalidation notice from the server. | 
| + void RecordRemoteInvalidation( | 
| + const ModelTypeInvalidationMap& invalidation_map); | 
| - // Clear all unserviced nudges. | 
| - void Reset(); | 
| + // These functions should be called to keep this class informed of the status | 
| + // of the connection to the invalidations server. | 
| + void InvalidationsEnabled(); | 
| 
tim (not reviewing)
2013/05/06 21:29:04
Convention in Chrome for something like this would
 
rlarocque
2013/05/07 18:45:39
Done.
 | 
| + void InvalidationsDisabled(); | 
| - // Returns the coalesced source info. | 
| - const SyncSourceInfo& source_info() const { | 
| - return source_info_; | 
| - } | 
| + // A helper to return an old-style source info. Used only to maintain | 
| + // compatibility with some old code. | 
| + SyncSourceInfo source_info() const; | 
| - // Returns the set of locally modified types, according to our tracked source | 
| - // infos. The result is often wrong; see implementation comment for details. | 
| + // Returns the set of locally modified types, according to the nudges received | 
| + // since the last successful sync cycle. | 
| ModelTypeSet GetLocallyModifiedTypes() const; | 
| + // Returns the 'source' of the GetUpdate request. | 
| + // | 
| + // This flag is deprecated, but still used by the server. There can be more | 
| + // than one reason to perform a particular sync cycle. The GetUpdatesTrigger | 
| + // message will contain more reliable information about the reasons for | 
| + // performing a sync. | 
| + // | 
| + // See the implementation for important information about the coalesce logic. | 
| + sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source() const; | 
| + | 
| + // Fills a ProgressMarker for the next GetUpdates request. This is used by | 
| + // the DownloadUpdatesCommand to dump lots of useful per-type state | 
| + // information into the GetUpdate request before sending it off to the server. | 
| + void FillProtoMessage( | 
| + ModelType type, | 
| + sync_pb::GetUpdateTriggers* msg) const; | 
| + | 
| private: | 
| - // Merged source info for the nudge(s). | 
| - SyncSourceInfo source_info_; | 
| + typedef std::list<std::string> PayloadList; | 
| + typedef std::map<ModelType, PayloadList> PayloadListMap; | 
| + typedef std::map<ModelType, int> NudgeMap; | 
| + | 
| + // Merged updates source. This should be obsolete, but the server still | 
| + // relies on it for some heuristics. | 
| + sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source_; | 
| + | 
| + // The number of times each type has been locally nudged since the last | 
| + // successful sync cycle. If a type is not in the map, the count is zero. | 
| + NudgeMap local_nudge_counts_; | 
| + | 
| + // The number of times a refresh was requested each type, since the last | 
| + // successful sync cycle. If a type is not in the map, the count is zero. | 
| + NudgeMap refresh_requested_counts_; | 
| + | 
| + // A map of datatypes to lists of hints. The hints are ordered from least | 
| + // recent to most recent. | 
| + PayloadListMap payload_list_map_; | 
| + | 
| + // Tracks the types for which the list of pending hints has overflowed, | 
| + // causing us to drop the oldest hints. | 
| + ModelTypeSet locally_dropped_payload_types_; | 
| + | 
| + // Tracks the types for which the invalidation server has notified us that it | 
| + // dropped some of its payloads. | 
| + ModelTypeSet server_dropped_payload_types_; | 
| + | 
| + // Tracks whether or not invalidations are currently enabled. | 
| + bool invalidations_enabled_; | 
| + | 
| + // This flag is set if suspect that some technical malfunction or known bug | 
| + // may have left us with some unserviced invalidations. | 
| + // | 
| + // Keeps track of whether or not we're fully in sync with the invalidation | 
| + // server. This can be false even if invalidations are enabled and working | 
| + // correctly. For example, until we get ack-tracking working properly, we | 
| + // won't persist invalidations between restarts, so we may be out of sync when | 
| + // we restart. The only way to get back into sync is to have invalidations | 
| + // enabled, then complete a sync cycle to make sure we're fully up to date. | 
| + bool invalidations_out_of_sync_; | 
| DISALLOW_COPY_AND_ASSIGN(NudgeTracker); | 
| }; |