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
3 // found in the LICENSE file.
5 #ifndef SYNC_ENGINE_SYNC_ENGINE_EVENT_H_
6 #define SYNC_ENGINE_SYNC_ENGINE_EVENT_H_
10 #include "base/observer_list.h"
11 #include "sync/base/sync_export.h"
12 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
20 struct SYNC_EXPORT_PRIVATE SyncEngineEvent
{
22 ////////////////////////////////////////////////////////////////
23 // Sent on entry of Syncer state machine
26 // SyncerCommand generated events.
29 // We have reached the SYNCER_END state in the main sync loop.
32 ////////////////////////////////////////////////////////////////
33 // Generated in response to specific protocol actions or events.
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
,
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.
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.
50 // This event is sent when types are throttled or unthrottled.
51 THROTTLED_TYPES_CHANGED
,
54 explicit SyncEngineEvent(EventCause cause
);
57 EventCause what_happened
;
59 // The last session used for syncing.
60 sessions::SyncSessionSnapshot snapshot
;
62 // Update-Client-Auth returns a new token for sync use.
63 std::string updated_token
;
65 // Time when scheduler will try to send request after backoff.
66 base::Time retry_time
;
68 // Set of types that are currently throttled.
69 ModelTypeSet throttled_types
;
72 class SYNC_EXPORT_PRIVATE SyncEngineEventListener
{
74 // TODO(tim): Consider splitting this up to multiple callbacks, rather than
75 // have to do Event e(type); OnSyncEngineEvent(e); at all callsites,
76 virtual void OnSyncEngineEvent(const SyncEngineEvent
& event
) = 0;
78 virtual ~SyncEngineEventListener() {}
83 #endif // SYNC_ENGINE_SYNC_ENGINE_EVENT_H_