Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: sync/sessions/sync_session.h

Issue 14963002: sync: Report GetUpdate triggers to the server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tests Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 to and from various SyncerCommands with the goal of converging the 7 // bundle to and from various SyncerCommands with the goal of converging the
8 // client view of data with that of the server. The commands twiddle with 8 // client view of data with that of the server. The commands twiddle with
9 // session status in response to events and hiccups along the way, set and 9 // session status in response to events and hiccups along the way, set and
10 // query session progress with regards to conflict resolution and applying 10 // query session progress with regards to conflict resolution and applying
(...skipping 18 matching lines...) Expand all
29 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 29 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
30 #include "sync/sessions/ordered_commit_set.h" 30 #include "sync/sessions/ordered_commit_set.h"
31 #include "sync/sessions/status_controller.h" 31 #include "sync/sessions/status_controller.h"
32 #include "sync/sessions/sync_session_context.h" 32 #include "sync/sessions/sync_session_context.h"
33 33
34 namespace syncer { 34 namespace syncer {
35 class ModelSafeWorker; 35 class ModelSafeWorker;
36 36
37 namespace sessions { 37 namespace sessions {
38 38
39 class NudgeTracker;
40
39 class SYNC_EXPORT_PRIVATE SyncSession { 41 class SYNC_EXPORT_PRIVATE SyncSession {
40 public: 42 public:
41 // The Delegate services events that occur during the session requiring an 43 // The Delegate services events that occur during the session requiring an
42 // explicit (and session-global) action, as opposed to events that are simply 44 // explicit (and session-global) action, as opposed to events that are simply
43 // recorded in per-session state. 45 // recorded in per-session state.
44 class SYNC_EXPORT_PRIVATE Delegate { 46 class SYNC_EXPORT_PRIVATE Delegate {
45 public: 47 public:
46 // The client was throttled and should cease-and-desist syncing activity 48 // The client was throttled and should cease-and-desist syncing activity
47 // until the specified time. 49 // until the specified time.
48 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) = 0; 50 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) = 0;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 virtual void OnSyncProtocolError( 88 virtual void OnSyncProtocolError(
87 const sessions::SyncSessionSnapshot& snapshot) = 0; 89 const sessions::SyncSessionSnapshot& snapshot) = 0;
88 90
89 protected: 91 protected:
90 virtual ~Delegate() {} 92 virtual ~Delegate() {}
91 }; 93 };
92 94
93 SyncSession(SyncSessionContext* context, 95 SyncSession(SyncSessionContext* context,
94 Delegate* delegate, 96 Delegate* delegate,
95 const SyncSourceInfo& source); 97 const SyncSourceInfo& source);
98 SyncSession(SyncSessionContext* context,
tim (not reviewing) 2013/05/06 21:29:04 Having factory methods with appropriate names that
rlarocque 2013/05/07 18:45:39 Done. I couldn't think of a good name for the non
99 Delegate* delegate,
100 const SyncSourceInfo& source,
101 const NudgeTracker* nudge_tracker);
96 ~SyncSession(); 102 ~SyncSession();
97 103
98 // Builds a thread-safe and read-only copy of the current session state. 104 // Builds a thread-safe and read-only copy of the current session state.
99 SyncSessionSnapshot TakeSnapshot() const; 105 SyncSessionSnapshot TakeSnapshot() const;
100 106
101 // Builds and sends a snapshot to the session context's listeners. 107 // Builds and sends a snapshot to the session context's listeners.
102 void SendEventNotification(SyncEngineEvent::EventCause cause); 108 void SendEventNotification(SyncEngineEvent::EventCause cause);
103 109
104 // TODO(akalin): Split this into context() and mutable_context(). 110 // TODO(akalin): Split this into context() and mutable_context().
105 SyncSessionContext* context() const { return context_; } 111 SyncSessionContext* context() const { return context_; }
106 Delegate* delegate() const { return delegate_; } 112 Delegate* delegate() const { return delegate_; }
107 const StatusController& status_controller() const { 113 const StatusController& status_controller() const {
108 return *status_controller_.get(); 114 return *status_controller_.get();
109 } 115 }
110 StatusController* mutable_status_controller() { 116 StatusController* mutable_status_controller() {
111 return status_controller_.get(); 117 return status_controller_.get();
112 } 118 }
113 119
114 const SyncSourceInfo& source() const { return source_; } 120 const SyncSourceInfo& source() const { return source_; }
115 121
122 const NudgeTracker* nudge_tracker() const { return nudge_tracker_; }
123
116 private: 124 private:
117 // The context for this session, guaranteed to outlive |this|. 125 // The context for this session, guaranteed to outlive |this|.
118 SyncSessionContext* const context_; 126 SyncSessionContext* const context_;
119 127
120 // The source for initiating this sync session. 128 // The source for initiating this sync session.
121 SyncSourceInfo source_; 129 SyncSourceInfo source_;
122 130
123 // The delegate for this session, must never be NULL. 131 // The delegate for this session, must never be NULL.
124 Delegate* const delegate_; 132 Delegate* const delegate_;
125 133
126 // Our controller for various status and error counters. 134 // Our controller for various status and error counters.
127 scoped_ptr<StatusController> status_controller_; 135 scoped_ptr<StatusController> status_controller_;
128 136
137 const NudgeTracker* nudge_tracker_;
138
129 DISALLOW_COPY_AND_ASSIGN(SyncSession); 139 DISALLOW_COPY_AND_ASSIGN(SyncSession);
130 }; 140 };
131 141
132 } // namespace sessions 142 } // namespace sessions
133 } // namespace syncer 143 } // namespace syncer
134 144
135 #endif // SYNC_SESSIONS_SYNC_SESSION_H_ 145 #endif // SYNC_SESSIONS_SYNC_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698