| 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 SYNC_SESSIONS_SYNC_SESSION_H_ |
| 11 #define SYNC_SESSIONS_SYNC_SESSION_H_ | 11 #define SYNC_SESSIONS_SYNC_SESSION_H_ |
| 12 | 12 |
| 13 #include <map> | 13 #include <map> |
| 14 #include <set> | 14 #include <set> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <utility> | 16 #include <utility> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
| 20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "sync/base/sync_export.h" | 22 #include "sync/base/sync_export.h" |
| 23 #include "sync/engine/sync_cycle_event.h" |
| 23 #include "sync/internal_api/public/base/model_type.h" | 24 #include "sync/internal_api/public/base/model_type.h" |
| 24 #include "sync/internal_api/public/engine/model_safe_worker.h" | 25 #include "sync/internal_api/public/engine/model_safe_worker.h" |
| 25 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 26 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 27 #include "sync/protocol/sync_protocol_error.h" |
| 26 #include "sync/sessions/status_controller.h" | 28 #include "sync/sessions/status_controller.h" |
| 27 #include "sync/sessions/sync_session_context.h" | 29 #include "sync/sessions/sync_session_context.h" |
| 28 | 30 |
| 29 namespace syncer { | 31 namespace syncer { |
| 30 class ModelSafeWorker; | 32 class ModelSafeWorker; |
| 31 | 33 |
| 32 namespace sessions { | 34 namespace sessions { |
| 33 | 35 |
| 34 class NudgeTracker; | 36 class NudgeTracker; |
| 35 | 37 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 virtual void OnReceivedLongPollIntervalUpdate( | 70 virtual void OnReceivedLongPollIntervalUpdate( |
| 69 const base::TimeDelta& new_interval) = 0; | 71 const base::TimeDelta& new_interval) = 0; |
| 70 | 72 |
| 71 // The client has been instructed to change its sessions commit | 73 // The client has been instructed to change its sessions commit |
| 72 // delay. | 74 // delay. |
| 73 virtual void OnReceivedSessionsCommitDelay( | 75 virtual void OnReceivedSessionsCommitDelay( |
| 74 const base::TimeDelta& new_delay) = 0; | 76 const base::TimeDelta& new_delay) = 0; |
| 75 | 77 |
| 76 // Called for the syncer to respond to the error sent by the server. | 78 // Called for the syncer to respond to the error sent by the server. |
| 77 virtual void OnSyncProtocolError( | 79 virtual void OnSyncProtocolError( |
| 78 const sessions::SyncSessionSnapshot& snapshot) = 0; | 80 const SyncProtocolError& sync_protocol_error) = 0; |
| 79 | 81 |
| 80 // Called when the server wants to change the number of hints the client | 82 // Called when the server wants to change the number of hints the client |
| 81 // will buffer locally. | 83 // will buffer locally. |
| 82 virtual void OnReceivedClientInvalidationHintBufferSize(int size) = 0; | 84 virtual void OnReceivedClientInvalidationHintBufferSize(int size) = 0; |
| 83 | 85 |
| 84 // Called when server wants to schedule a retry GU. | 86 // Called when server wants to schedule a retry GU. |
| 85 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) = 0; | 87 virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) = 0; |
| 86 | 88 |
| 87 protected: | 89 protected: |
| 88 virtual ~Delegate() {} | 90 virtual ~Delegate() {} |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 // Build a session without a nudge tracker. Used for poll or configure type | 93 // Build a session without a nudge tracker. Used for poll or configure type |
| 92 // sync cycles. | 94 // sync cycles. |
| 93 static SyncSession* Build(SyncSessionContext* context, | 95 static SyncSession* Build(SyncSessionContext* context, |
| 94 Delegate* delegate); | 96 Delegate* delegate); |
| 95 ~SyncSession(); | 97 ~SyncSession(); |
| 96 | 98 |
| 97 // Builds a thread-safe and read-only copy of the current session state. | 99 // Builds a thread-safe and read-only copy of the current session state. |
| 98 SyncSessionSnapshot TakeSnapshot() const; | 100 SyncSessionSnapshot TakeSnapshot() const; |
| 99 SyncSessionSnapshot TakeSnapshotWithSource( | 101 SyncSessionSnapshot TakeSnapshotWithSource( |
| 100 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source) | 102 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source) |
| 101 const; | 103 const; |
| 102 | 104 |
| 103 // Builds and sends a snapshot to the session context's listeners. | 105 // Builds and sends a snapshot to the session context's listeners. |
| 104 void SendSyncCycleEndEventNotification( | 106 void SendSyncCycleEndEventNotification( |
| 105 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); | 107 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source); |
| 106 void SendEventNotification(SyncEngineEvent::EventCause cause); | 108 void SendEventNotification(SyncCycleEvent::EventCause cause); |
| 107 | 109 |
| 108 // TODO(akalin): Split this into context() and mutable_context(). | 110 // TODO(akalin): Split this into context() and mutable_context(). |
| 109 SyncSessionContext* context() const { return context_; } | 111 SyncSessionContext* context() const { return context_; } |
| 110 Delegate* delegate() const { return delegate_; } | 112 Delegate* delegate() const { return delegate_; } |
| 111 const StatusController& status_controller() const { | 113 const StatusController& status_controller() const { |
| 112 return *status_controller_.get(); | 114 return *status_controller_.get(); |
| 113 } | 115 } |
| 114 StatusController* mutable_status_controller() { | 116 StatusController* mutable_status_controller() { |
| 115 return status_controller_.get(); | 117 return status_controller_.get(); |
| 116 } | 118 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 127 // Our controller for various status and error counters. | 129 // Our controller for various status and error counters. |
| 128 scoped_ptr<StatusController> status_controller_; | 130 scoped_ptr<StatusController> status_controller_; |
| 129 | 131 |
| 130 DISALLOW_COPY_AND_ASSIGN(SyncSession); | 132 DISALLOW_COPY_AND_ASSIGN(SyncSession); |
| 131 }; | 133 }; |
| 132 | 134 |
| 133 } // namespace sessions | 135 } // namespace sessions |
| 134 } // namespace syncer | 136 } // namespace syncer |
| 135 | 137 |
| 136 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ | 138 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ |
| OLD | NEW |