1 // Copyright 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef SYNC_SESSIONS_MODEL_NEUTRAL_STATE_H 6 #define SYNC_SESSIONS_MODEL_NEUTRAL_STATE_H 7 8 #include "base/basictypes.h" 9 #include "sync/base/sync_export.h" 10 #include "sync/internal_api/public/util/syncer_error.h" 11 #include "sync/protocol/sync.pb.h" 12 #include "sync/protocol/sync_protocol_error.h" 13 14 namespace syncer { 15 namespace sessions { 16 17 // Grouping of all state that applies to all model types. Note that some 18 // components of the global grouping can internally implement finer grained 19 // scope control, but the top level entity is still a singleton with respect to 20 // model types. 21 struct SYNC_EXPORT ModelNeutralState { 22 ModelNeutralState(); 23 ~ModelNeutralState(); 24 25 // We GetUpdates for some combination of types at once. 26 // requested_update_types stores the set of types which were requested. 27 ModelTypeSet updates_request_types; 28 29 // The set of types for which commits were sent to the server. 30 ModelTypeSet commit_request_types; 31 32 sync_pb::ClientToServerResponse updates_response; 33 34 int num_successful_commits; 35 36 // This is needed for monitoring extensions activity. 37 int num_successful_bookmark_commits; 38 39 // Download event counters. 40 int num_updates_downloaded_total; 41 int num_tombstone_updates_downloaded_total; 42 int num_reflected_updates_downloaded_total; 43 44 // If the syncer encountered a MIGRATION_DONE code, these are the types that 45 // the client must now "migrate", by purging and re-downloading all updates. 46 ModelTypeSet types_needing_local_migration; 47 48 // Update application and conflicts. 49 int num_updates_applied; 50 int num_encryption_conflicts; 51 int num_server_conflicts; 52 int num_hierarchy_conflicts; 53 54 // Overwrites due to conflict resolution counters. 55 int num_local_overwrites; 56 int num_server_overwrites; 57 58 // Any protocol errors that we received during this sync session. 59 SyncProtocolError sync_protocol_error; 60 61 // Records the most recent results of GetKey, PostCommit and GetUpdates 62 // commands. 63 SyncerError last_get_key_result; 64 SyncerError last_download_updates_result; 65 SyncerError commit_result; 66 67 // Set to true by PostCommitMessageCommand if any commits were successful. 68 bool items_committed; 69 70 // True indicates debug info has been sent once this session. 71 bool debug_info_sent; 72 73 // Number of changes remaining, according to the server. 74 // Take it as an estimate unless it's value is zero, in which case there 75 // really is nothing more to download. 76 int64 num_server_changes_remaining; 77 }; 78 79 bool HasSyncerError(const ModelNeutralState& state); 80 81 } // namespace sessions 82 } // namespace syncer 83 84 #endif // SYNC_SESSIONS_MODEL_NEUTRAL_STATE_H_ 85