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/syncable/model_type.h" | 26 #include "chrome/browser/sync/syncable/model_type.h" |
27 #include "chrome/browser/sync/syncable/model_type_payload_map.h" | 27 #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
28 #include "chrome/browser/sync/syncable/syncable.h" | 28 #include "chrome/browser/sync/syncable/syncable.h" |
29 | 29 |
| 30 namespace base { |
30 class DictionaryValue; | 31 class DictionaryValue; |
| 32 } |
31 | 33 |
32 namespace syncable { | 34 namespace syncable { |
33 class DirectoryManager; | 35 class DirectoryManager; |
34 } | 36 } |
35 | 37 |
36 namespace browser_sync { | 38 namespace browser_sync { |
37 namespace sessions { | 39 namespace sessions { |
38 | 40 |
39 class UpdateProgress; | 41 class UpdateProgress; |
40 | 42 |
41 // A container for the source of a sync session. This includes the update | 43 // A container for the source of a sync session. This includes the update |
42 // source, the datatypes triggering the sync session, and possible session | 44 // source, the datatypes triggering the sync session, and possible session |
43 // specific payloads which should be sent to the server. | 45 // specific payloads which should be sent to the server. |
44 struct SyncSourceInfo { | 46 struct SyncSourceInfo { |
45 SyncSourceInfo(); | 47 SyncSourceInfo(); |
46 explicit SyncSourceInfo(const syncable::ModelTypePayloadMap& t); | 48 explicit SyncSourceInfo(const syncable::ModelTypePayloadMap& t); |
47 SyncSourceInfo( | 49 SyncSourceInfo( |
48 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u, | 50 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource& u, |
49 const syncable::ModelTypePayloadMap& t); | 51 const syncable::ModelTypePayloadMap& t); |
50 ~SyncSourceInfo(); | 52 ~SyncSourceInfo(); |
51 | 53 |
52 // Caller takes ownership of the returned dictionary. | 54 // Caller takes ownership of the returned dictionary. |
53 DictionaryValue* ToValue() const; | 55 base::DictionaryValue* ToValue() const; |
54 | 56 |
55 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source; | 57 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source; |
56 syncable::ModelTypePayloadMap types; | 58 syncable::ModelTypePayloadMap types; |
57 }; | 59 }; |
58 | 60 |
59 // Data pertaining to the status of an active Syncer object. | 61 // Data pertaining to the status of an active Syncer object. |
60 struct SyncerStatus { | 62 struct SyncerStatus { |
61 SyncerStatus(); | 63 SyncerStatus(); |
62 ~SyncerStatus(); | 64 ~SyncerStatus(); |
63 | 65 |
64 // Caller takes ownership of the returned dictionary. | 66 // Caller takes ownership of the returned dictionary. |
65 DictionaryValue* ToValue() const; | 67 base::DictionaryValue* ToValue() const; |
66 | 68 |
67 // True when we get such an INVALID_STORE error from the server. | 69 // True when we get such an INVALID_STORE error from the server. |
68 bool invalid_store; | 70 bool invalid_store; |
69 // True iff we're stuck. | 71 // True iff we're stuck. |
70 bool syncer_stuck; | 72 bool syncer_stuck; |
71 bool syncing; | 73 bool syncing; |
72 int num_successful_commits; | 74 int num_successful_commits; |
73 // This is needed for monitoring extensions activity. | 75 // This is needed for monitoring extensions activity. |
74 int num_successful_bookmark_commits; | 76 int num_successful_bookmark_commits; |
75 | 77 |
76 // Download event counters. | 78 // Download event counters. |
77 int num_updates_downloaded_total; | 79 int num_updates_downloaded_total; |
78 int num_tombstone_updates_downloaded_total; | 80 int num_tombstone_updates_downloaded_total; |
79 | 81 |
80 // If the syncer encountered a MIGRATION_DONE code, these are the types that | 82 // If the syncer encountered a MIGRATION_DONE code, these are the types that |
81 // the client must now "migrate", by purging and re-downloading all updates. | 83 // the client must now "migrate", by purging and re-downloading all updates. |
82 syncable::ModelTypeSet types_needing_local_migration; | 84 syncable::ModelTypeSet types_needing_local_migration; |
83 | 85 |
84 // Overwrites due to conflict resolution counters. | 86 // Overwrites due to conflict resolution counters. |
85 int num_local_overwrites; | 87 int num_local_overwrites; |
86 int num_server_overwrites; | 88 int num_server_overwrites; |
87 }; | 89 }; |
88 | 90 |
89 // Counters for various errors that can occur repeatedly during a sync session. | 91 // Counters for various errors that can occur repeatedly during a sync session. |
90 struct ErrorCounters { | 92 struct ErrorCounters { |
91 ErrorCounters(); | 93 ErrorCounters(); |
92 | 94 |
93 // Caller takes ownership of the returned dictionary. | 95 // Caller takes ownership of the returned dictionary. |
94 DictionaryValue* ToValue() const; | 96 base::DictionaryValue* ToValue() const; |
95 | 97 |
96 int num_conflicting_commits; | 98 int num_conflicting_commits; |
97 | 99 |
98 // Number of commits hitting transient errors since the last successful | 100 // Number of commits hitting transient errors since the last successful |
99 // commit. | 101 // commit. |
100 int consecutive_transient_error_commits; | 102 int consecutive_transient_error_commits; |
101 | 103 |
102 // Incremented when get_updates fails, commit fails, and when hitting | 104 // Incremented when get_updates fails, commit fails, and when hitting |
103 // transient errors. When any of these succeed, this counter is reset. | 105 // transient errors. When any of these succeed, this counter is reset. |
104 // TODO(chron): Reduce number of weird counters we use. | 106 // TODO(chron): Reduce number of weird counters we use. |
105 int consecutive_errors; | 107 int consecutive_errors; |
106 }; | 108 }; |
107 | 109 |
108 // Caller takes ownership of the returned dictionary. | 110 // Caller takes ownership of the returned dictionary. |
109 DictionaryValue* DownloadProgressMarkersToValue( | 111 base::DictionaryValue* DownloadProgressMarkersToValue( |
110 const std::string | 112 const std::string |
111 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT]); | 113 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT]); |
112 | 114 |
113 // An immutable snapshot of state from a SyncSession. Convenient to use as | 115 // An immutable snapshot of state from a SyncSession. Convenient to use as |
114 // part of notifications as it is inherently thread-safe. | 116 // part of notifications as it is inherently thread-safe. |
115 struct SyncSessionSnapshot { | 117 struct SyncSessionSnapshot { |
116 SyncSessionSnapshot( | 118 SyncSessionSnapshot( |
117 const SyncerStatus& syncer_status, | 119 const SyncerStatus& syncer_status, |
118 const ErrorCounters& errors, | 120 const ErrorCounters& errors, |
119 int64 num_server_changes_remaining, | 121 int64 num_server_changes_remaining, |
120 bool is_share_usable, | 122 bool is_share_usable, |
121 const syncable::ModelTypeBitSet& initial_sync_ended, | 123 const syncable::ModelTypeBitSet& initial_sync_ended, |
122 const std::string | 124 const std::string |
123 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], | 125 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], |
124 bool more_to_sync, | 126 bool more_to_sync, |
125 bool is_silenced, | 127 bool is_silenced, |
126 int64 unsynced_count, | 128 int64 unsynced_count, |
127 int num_blocking_conflicting_updates, | 129 int num_blocking_conflicting_updates, |
128 int num_conflicting_updates, | 130 int num_conflicting_updates, |
129 bool did_commit_items, | 131 bool did_commit_items, |
130 const SyncSourceInfo& source, | 132 const SyncSourceInfo& source, |
131 size_t num_entries); | 133 size_t num_entries); |
132 ~SyncSessionSnapshot(); | 134 ~SyncSessionSnapshot(); |
133 | 135 |
134 // Caller takes ownership of the returned dictionary. | 136 // Caller takes ownership of the returned dictionary. |
135 DictionaryValue* ToValue() const; | 137 base::DictionaryValue* ToValue() const; |
136 | 138 |
137 std::string ToString() const; | 139 std::string ToString() const; |
138 | 140 |
139 const SyncerStatus syncer_status; | 141 const SyncerStatus syncer_status; |
140 const ErrorCounters errors; | 142 const ErrorCounters errors; |
141 const int64 num_server_changes_remaining; | 143 const int64 num_server_changes_remaining; |
142 const bool is_share_usable; | 144 const bool is_share_usable; |
143 const syncable::ModelTypeBitSet initial_sync_ended; | 145 const syncable::ModelTypeBitSet initial_sync_ended; |
144 const std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | 146 const std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; |
145 const bool has_more_to_sync; | 147 const bool has_more_to_sync; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 ~PerModelSafeGroupState(); | 329 ~PerModelSafeGroupState(); |
328 | 330 |
329 UpdateProgress update_progress; | 331 UpdateProgress update_progress; |
330 ConflictProgress conflict_progress; | 332 ConflictProgress conflict_progress; |
331 }; | 333 }; |
332 | 334 |
333 } // namespace sessions | 335 } // namespace sessions |
334 } // namespace browser_sync | 336 } // namespace browser_sync |
335 | 337 |
336 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ | 338 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ |
OLD | NEW |