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

Side by Side Diff: sync/engine/sync_engine_event.h

Issue 152013003: Split up SyncEngineEventListener callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try to fix chunk mismatch Created 6 years, 10 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 | Annotate | Revision Log
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 #ifndef SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ 5 #ifndef SYNC_ENGINE_SYNC_ENGINE_EVENT_H_
6 #define SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ 6 #define SYNC_ENGINE_SYNC_ENGINE_EVENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/observer_list.h"
11 #include "sync/base/sync_export.h" 10 #include "sync/base/sync_export.h"
12 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 11 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
13 12 #include "sync/protocol/sync_protocol_error.h"
Nicolas Zea 2014/02/10 23:15:16 Can forward declare this
rlarocque 2014/02/11 00:19:43 Done.
14 namespace syncable {
15 class Id;
16 }
17 13
18 namespace syncer { 14 namespace syncer {
19 15
20 struct SYNC_EXPORT_PRIVATE SyncEngineEvent { 16 struct SYNC_EXPORT_PRIVATE SyncCycleEvent {
Nicolas Zea 2014/02/10 23:15:16 Possibly move to its own file?
rlarocque 2014/02/11 00:19:43 Done.
21 enum EventCause { 17 enum EventCause {
22 //////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////////////////////////
23 // Sent on entry of Syncer state machine 19 // Sent on entry of Syncer state machine
24 SYNC_CYCLE_BEGIN, 20 SYNC_CYCLE_BEGIN,
25 21
26 // Sent any time progress is made during a sync cycle. 22 // Sent any time progress is made during a sync cycle.
27 STATUS_CHANGED, 23 STATUS_CHANGED,
28 24
29 // We have reached the SYNCER_END state in the main sync loop. 25 // We have reached the SYNCER_END state in the main sync loop.
30 SYNC_CYCLE_ENDED, 26 SYNC_CYCLE_ENDED,
31
32 ////////////////////////////////////////////////////////////////
33 // Generated in response to specific protocol actions or events.
34
35 // This is sent after the Syncer (and SyncerThread) have initiated self
36 // halt due to no longer being permitted to communicate with the server.
37 // The listener should sever the sync / browser connections and delete sync
38 // data (i.e. as if the user clicked 'Stop Syncing' in the browser.
39 STOP_SYNCING_PERMANENTLY,
Nicolas Zea 2014/02/10 23:15:16 How is STOP_SYNCING_PERMANENTLY being handled now?
rlarocque 2014/02/11 00:19:43 As far as I can tell, it's not handled at all. Ac
40
41 // This event is sent when we receive an actionable error. It is upto
42 // the listeners to figure out the action to take using the snapshot sent.
43 ACTIONABLE_ERROR,
44
45 // This event is sent when scheduler decides to wait before next request
46 // either because it gets throttled by server or because it backs off after
47 // request failure. Retry time is passed in retry_time field of event.
48 RETRY_TIME_CHANGED,
49
50 // This event is sent when types are throttled or unthrottled.
51 THROTTLED_TYPES_CHANGED,
52 }; 27 };
53 28
54 explicit SyncEngineEvent(EventCause cause); 29 explicit SyncCycleEvent(EventCause cause);
55 ~SyncEngineEvent(); 30 ~SyncCycleEvent();
56 31
57 EventCause what_happened; 32 EventCause what_happened;
58 33
59 // The last session used for syncing. 34 // The last session used for syncing.
60 sessions::SyncSessionSnapshot snapshot; 35 sessions::SyncSessionSnapshot snapshot;
61
62 // Update-Client-Auth returns a new token for sync use.
63 std::string updated_token;
64
65 // Time when scheduler will try to send request after backoff.
66 base::Time retry_time;
67
68 // Set of types that are currently throttled.
69 ModelTypeSet throttled_types;
70 }; 36 };
71 37
72 class SYNC_EXPORT_PRIVATE SyncEngineEventListener { 38 class SYNC_EXPORT_PRIVATE SyncEngineEventListener {
Nicolas Zea 2014/02/10 23:15:16 This file should probably be renamed sync_engine_e
rlarocque 2014/02/11 00:19:43 Done.
73 public: 39 public:
74 // TODO(tim): Consider splitting this up to multiple callbacks, rather than 40 // Generated at various points during the sync cycle.
75 // have to do Event e(type); OnSyncEngineEvent(e); at all callsites, 41 virtual void OnSyncCycleEvent(const SyncCycleEvent& event) = 0;
76 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) = 0; 42
43 // This event is sent when we receive an actionable error. It is up to
44 // the listeners to figure out the action to take using the error sent.
45 virtual void OnActionableError(const SyncProtocolError& error) = 0;
46
47 // This event is sent when scheduler decides to wait before next request
48 // either because it gets throttled by server or because it backs off after
49 // request failure. Retry time is passed in retry_time field of event.
50 virtual void OnRetryTimeChanged(base::Time retry_time) = 0;
51
52 // This event is sent when types are throttled or unthrottled.
53 virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) = 0;
54
77 protected: 55 protected:
78 virtual ~SyncEngineEventListener() {} 56 virtual ~SyncEngineEventListener() {}
79 }; 57 };
80 58
81 } // namespace syncer 59 } // namespace syncer
82 60
83 #endif // SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ 61 #endif // SYNC_ENGINE_SYNC_ENGINE_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698