OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 // A class representing an attempt to synchronize the local syncable data | 5 // A class representing an attempt to synchronize the local syncable data |
6 // store with a sync server. A SyncSession instance is passed as a stateful | 6 // store with a sync server. A SyncSession instance is passed as a stateful |
7 // bundle throughout the sync cycle. The SyncSession is not reused across | 7 // bundle throughout the sync cycle. The SyncSession is not reused across |
8 // sync cycles; each cycle starts with a new one. | 8 // sync cycles; each cycle starts with a new one. |
9 | 9 |
10 #ifndef SYNC_SESSIONS_SYNC_SESSION_H_ | 10 #ifndef COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_H_ |
11 #define SYNC_SESSIONS_SYNC_SESSION_H_ | 11 #define COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_H_ |
12 | 12 |
13 #include <map> | 13 #include <map> |
14 #include <memory> | 14 #include <memory> |
15 #include <set> | 15 #include <set> |
16 #include <string> | 16 #include <string> |
17 #include <utility> | 17 #include <utility> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "sync/base/sync_export.h" | 22 #include "components/sync/base/model_type.h" |
23 #include "sync/engine/sync_cycle_event.h" | 23 #include "components/sync/base/sync_export.h" |
24 #include "sync/internal_api/public/base/model_type.h" | 24 #include "components/sync/engine/model_safe_worker.h" |
25 #include "sync/internal_api/public/engine/model_safe_worker.h" | 25 #include "components/sync/engine_impl/sync_cycle_event.h" |
26 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 26 #include "components/sync/protocol/sync_protocol_error.h" |
27 #include "sync/protocol/sync_protocol_error.h" | 27 #include "components/sync/sessions/sync_session_snapshot.h" |
28 #include "sync/sessions/status_controller.h" | 28 #include "components/sync/sessions_impl/status_controller.h" |
29 #include "sync/sessions/sync_session_context.h" | 29 #include "components/sync/sessions_impl/sync_session_context.h" |
30 | 30 |
31 namespace syncer { | 31 namespace syncer { |
32 class ModelSafeWorker; | 32 class ModelSafeWorker; |
33 class ProtocolEvent; | 33 class ProtocolEvent; |
34 | 34 |
35 namespace sessions { | 35 namespace sessions { |
36 | 36 |
37 class NudgeTracker; | 37 class NudgeTracker; |
38 | 38 |
39 class SYNC_EXPORT SyncSession { | 39 class SYNC_EXPORT SyncSession { |
40 public: | 40 public: |
41 // The Delegate services events that occur during the session requiring an | 41 // The Delegate services events that occur during the session requiring an |
42 // explicit (and session-global) action, as opposed to events that are simply | 42 // explicit (and session-global) action, as opposed to events that are simply |
43 // recorded in per-session state. | 43 // recorded in per-session state. |
44 class SYNC_EXPORT Delegate { | 44 class SYNC_EXPORT Delegate { |
45 public: | 45 public: |
46 // The client was throttled and should cease-and-desist syncing activity | 46 // The client was throttled and should cease-and-desist syncing activity |
47 // until the specified time. | 47 // until the specified time. |
48 virtual void OnThrottled(const base::TimeDelta& throttle_duration) = 0; | 48 virtual void OnThrottled(const base::TimeDelta& throttle_duration) = 0; |
49 | 49 |
50 // Some of the client's types were throttled. | 50 // Some of the client's types were throttled. |
51 virtual void OnTypesThrottled( | 51 virtual void OnTypesThrottled(ModelTypeSet types, |
52 ModelTypeSet types, | 52 const base::TimeDelta& throttle_duration) = 0; |
53 const base::TimeDelta& throttle_duration) = 0; | |
54 | 53 |
55 // Silenced intervals can be out of phase with individual sessions, so the | 54 // Silenced intervals can be out of phase with individual sessions, so the |
56 // delegate is the only thing that can give an authoritative answer for | 55 // delegate is the only thing that can give an authoritative answer for |
57 // "is syncing silenced right now". This shouldn't be necessary very often | 56 // "is syncing silenced right now". This shouldn't be necessary very often |
58 // as the delegate ensures no session is started if syncing is silenced. | 57 // as the delegate ensures no session is started if syncing is silenced. |
59 // ** Note ** This will return true if silencing commenced during this | 58 // ** Note ** This will return true if silencing commenced during this |
60 // session and the interval has not yet elapsed, but the contract here is | 59 // session and the interval has not yet elapsed, but the contract here is |
61 // solely based on absolute time values. So, this cannot be used to infer | 60 // solely based on absolute time values. So, this cannot be used to infer |
62 // that any given session _instance_ is silenced. An example of reasonable | 61 // that any given session _instance_ is silenced. An example of reasonable |
63 // use is for UI reporting. | 62 // use is for UI reporting. |
(...skipping 24 matching lines...) Expand all Loading... |
88 | 87 |
89 // Called when server requests a migration. | 88 // Called when server requests a migration. |
90 virtual void OnReceivedMigrationRequest(ModelTypeSet types) = 0; | 89 virtual void OnReceivedMigrationRequest(ModelTypeSet types) = 0; |
91 | 90 |
92 protected: | 91 protected: |
93 virtual ~Delegate() {} | 92 virtual ~Delegate() {} |
94 }; | 93 }; |
95 | 94 |
96 // Build a session without a nudge tracker. Used for poll or configure type | 95 // Build a session without a nudge tracker. Used for poll or configure type |
97 // sync cycles. | 96 // sync cycles. |
98 static SyncSession* Build(SyncSessionContext* context, | 97 static SyncSession* Build(SyncSessionContext* context, Delegate* delegate); |
99 Delegate* delegate); | |
100 ~SyncSession(); | 98 ~SyncSession(); |
101 | 99 |
102 // Builds a thread-safe and read-only copy of the current session state. | 100 // Builds a thread-safe and read-only copy of the current session state. |
103 SyncSessionSnapshot TakeSnapshot() const; | 101 SyncSessionSnapshot TakeSnapshot() const; |
104 SyncSessionSnapshot TakeSnapshotWithSource( | 102 SyncSessionSnapshot TakeSnapshotWithSource( |
105 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source) | 103 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source) |
106 const; | 104 const; |
107 | 105 |
108 // Builds and sends a snapshot to the session context's listeners. | 106 // Builds and sends a snapshot to the session context's listeners. |
109 void SendSyncCycleEndEventNotification( | 107 void SendSyncCycleEndEventNotification( |
(...skipping 23 matching lines...) Expand all Loading... |
133 | 131 |
134 // Our controller for various status and error counters. | 132 // Our controller for various status and error counters. |
135 std::unique_ptr<StatusController> status_controller_; | 133 std::unique_ptr<StatusController> status_controller_; |
136 | 134 |
137 DISALLOW_COPY_AND_ASSIGN(SyncSession); | 135 DISALLOW_COPY_AND_ASSIGN(SyncSession); |
138 }; | 136 }; |
139 | 137 |
140 } // namespace sessions | 138 } // namespace sessions |
141 } // namespace syncer | 139 } // namespace syncer |
142 | 140 |
143 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ | 141 #endif // COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_H_ |
OLD | NEW |