| OLD | NEW |
| 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 // The 'sessions' namespace comprises all the pieces of state that are | 5 // The 'sessions' namespace comprises all the pieces of state that are |
| 6 // combined to form a SyncSession instance. In that way, it can be thought of | 6 // combined to form a SyncSession instance. In that way, it can be thought of |
| 7 // as an extension of the SyncSession type itself. Session scoping gives | 7 // as an extension of the SyncSession type itself. Session scoping gives |
| 8 // context to things like "conflict progress", "update progress", etc, and the | 8 // context to things like "conflict progress", "update progress", etc, and the |
| 9 // separation this file provides allows clients to only include the parts they | 9 // separation this file provides allows clients to only include the parts they |
| 10 // need rather than the entire session stack. | 10 // need rather than the entire session stack. |
| 11 | 11 |
| 12 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ | 12 #ifndef CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ |
| 13 #define CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ | 13 #define CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ |
| 14 #pragma once | 14 #pragma once |
| 15 | 15 |
| 16 #include <map> | 16 #include <map> |
| 17 #include <set> | 17 #include <set> |
| 18 #include <string> | 18 #include <string> |
| 19 #include <utility> | 19 #include <utility> |
| 20 #include <vector> | 20 #include <vector> |
| 21 | 21 |
| 22 #include "base/basictypes.h" | 22 #include "base/basictypes.h" |
| 23 #include "chrome/browser/sync/engine/syncer_types.h" | 23 #include "chrome/browser/sync/engine/syncer_types.h" |
| 24 #include "chrome/browser/sync/engine/syncproto.h" | 24 #include "chrome/browser/sync/engine/syncproto.h" |
| 25 #include "chrome/browser/sync/sessions/ordered_commit_set.h" | 25 #include "chrome/browser/sync/sessions/ordered_commit_set.h" |
| 26 #include "chrome/browser/sync/protocol/sync_protocol_error.h" |
| 26 #include "chrome/browser/sync/syncable/model_type.h" | 27 #include "chrome/browser/sync/syncable/model_type.h" |
| 27 #include "chrome/browser/sync/syncable/model_type_payload_map.h" | 28 #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
| 28 #include "chrome/browser/sync/syncable/syncable.h" | 29 #include "chrome/browser/sync/syncable/syncable.h" |
| 29 | 30 |
| 30 namespace base { | 31 namespace base { |
| 31 class DictionaryValue; | 32 class DictionaryValue; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace syncable { | 35 namespace syncable { |
| 35 class DirectoryManager; | 36 class DirectoryManager; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // If the syncer encountered a MIGRATION_DONE code, these are the types that | 83 // If the syncer encountered a MIGRATION_DONE code, these are the types that |
| 83 // the client must now "migrate", by purging and re-downloading all updates. | 84 // the client must now "migrate", by purging and re-downloading all updates. |
| 84 syncable::ModelTypeSet types_needing_local_migration; | 85 syncable::ModelTypeSet types_needing_local_migration; |
| 85 | 86 |
| 86 // Overwrites due to conflict resolution counters. | 87 // Overwrites due to conflict resolution counters. |
| 87 int num_local_overwrites; | 88 int num_local_overwrites; |
| 88 int num_server_overwrites; | 89 int num_server_overwrites; |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 // Counters for various errors that can occur repeatedly during a sync session. | 92 // Counters for various errors that can occur repeatedly during a sync session. |
| 93 // TODO(lipalani) : Rename this structure to Error. |
| 92 struct ErrorCounters { | 94 struct ErrorCounters { |
| 93 ErrorCounters(); | 95 ErrorCounters(); |
| 94 | 96 |
| 95 // Caller takes ownership of the returned dictionary. | 97 // Caller takes ownership of the returned dictionary. |
| 96 base::DictionaryValue* ToValue() const; | 98 base::DictionaryValue* ToValue() const; |
| 97 | 99 |
| 98 int num_conflicting_commits; | 100 int num_conflicting_commits; |
| 99 | 101 |
| 100 // Number of commits hitting transient errors since the last successful | 102 // Number of commits hitting transient errors since the last successful |
| 101 // commit. | 103 // commit. |
| 102 int consecutive_transient_error_commits; | 104 int consecutive_transient_error_commits; |
| 103 | 105 |
| 104 // Incremented when get_updates fails, commit fails, and when hitting | 106 // Incremented when get_updates fails, commit fails, and when hitting |
| 105 // transient errors. When any of these succeed, this counter is reset. | 107 // transient errors. When any of these succeed, this counter is reset. |
| 106 // TODO(chron): Reduce number of weird counters we use. | 108 // TODO(chron): Reduce number of weird counters we use. |
| 107 int consecutive_errors; | 109 int consecutive_errors; |
| 110 |
| 111 // Any protocol errors that we received during this sync session. |
| 112 SyncProtocolError sync_protocol_error; |
| 108 }; | 113 }; |
| 109 | 114 |
| 110 // Caller takes ownership of the returned dictionary. | 115 // Caller takes ownership of the returned dictionary. |
| 111 base::DictionaryValue* DownloadProgressMarkersToValue( | 116 base::DictionaryValue* DownloadProgressMarkersToValue( |
| 112 const std::string | 117 const std::string |
| 113 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT]); | 118 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT]); |
| 114 | 119 |
| 115 // An immutable snapshot of state from a SyncSession. Convenient to use as | 120 // An immutable snapshot of state from a SyncSession. Convenient to use as |
| 116 // part of notifications as it is inherently thread-safe. | 121 // part of notifications as it is inherently thread-safe. |
| 117 struct SyncSessionSnapshot { | 122 struct SyncSessionSnapshot { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // Commits for all model types are bundled together into a single message. | 318 // Commits for all model types are bundled together into a single message. |
| 314 ClientToServerMessage commit_message; | 319 ClientToServerMessage commit_message; |
| 315 ClientToServerResponse commit_response; | 320 ClientToServerResponse commit_response; |
| 316 // We GetUpdates for some combination of types at once. | 321 // We GetUpdates for some combination of types at once. |
| 317 // requested_update_types stores the set of types which were requested. | 322 // requested_update_types stores the set of types which were requested. |
| 318 syncable::ModelTypeBitSet updates_request_types; | 323 syncable::ModelTypeBitSet updates_request_types; |
| 319 ClientToServerResponse updates_response; | 324 ClientToServerResponse updates_response; |
| 320 // Used to build the shared commit message. | 325 // Used to build the shared commit message. |
| 321 DirtyOnWrite<std::vector<int64> > unsynced_handles; | 326 DirtyOnWrite<std::vector<int64> > unsynced_handles; |
| 322 DirtyOnWrite<SyncerStatus> syncer_status; | 327 DirtyOnWrite<SyncerStatus> syncer_status; |
| 323 DirtyOnWrite<ErrorCounters> error_counters; | 328 DirtyOnWrite<ErrorCounters> error; |
| 324 SyncCycleControlParameters control_params; | 329 SyncCycleControlParameters control_params; |
| 325 DirtyOnWrite<int64> num_server_changes_remaining; | 330 DirtyOnWrite<int64> num_server_changes_remaining; |
| 326 OrderedCommitSet commit_set; | 331 OrderedCommitSet commit_set; |
| 327 }; | 332 }; |
| 328 | 333 |
| 329 // Grouping of all state that applies to a single ModelSafeGroup. | 334 // Grouping of all state that applies to a single ModelSafeGroup. |
| 330 struct PerModelSafeGroupState { | 335 struct PerModelSafeGroupState { |
| 331 explicit PerModelSafeGroupState(bool* dirty_flag); | 336 explicit PerModelSafeGroupState(bool* dirty_flag); |
| 332 ~PerModelSafeGroupState(); | 337 ~PerModelSafeGroupState(); |
| 333 | 338 |
| 334 UpdateProgress update_progress; | 339 UpdateProgress update_progress; |
| 335 ConflictProgress conflict_progress; | 340 ConflictProgress conflict_progress; |
| 336 }; | 341 }; |
| 337 | 342 |
| 338 } // namespace sessions | 343 } // namespace sessions |
| 339 } // namespace browser_sync | 344 } // namespace browser_sync |
| 340 | 345 |
| 341 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ | 346 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ |
| OLD | NEW |