Refactor management of overview window copy lifetime into a separate class.
[chromium-blink-merge.git] / sync / engine / sync_engine_event.h
blob25f9692fc7ca738cf1018b99d20ea3619f74f78d
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_
8 #include <string>
10 #include "base/observer_list.h"
11 #include "sync/base/sync_export.h"
12 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
14 namespace syncable {
15 class Id;
18 namespace syncer {
20 struct SYNC_EXPORT_PRIVATE SyncEngineEvent {
21 enum EventCause {
22 ////////////////////////////////////////////////////////////////
23 // Sent on entry of Syncer state machine
24 SYNC_CYCLE_BEGIN,
26 // SyncerCommand generated events.
27 STATUS_CHANGED,
29 // We have reached the SYNCER_END state in the main sync loop.
30 SYNC_CYCLE_ENDED,
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.
43 ACTIONABLE_ERROR,
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,
50 // This event is sent when types are throttled or unthrottled.
51 THROTTLED_TYPES_CHANGED,
54 explicit SyncEngineEvent(EventCause cause);
55 ~SyncEngineEvent();
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 {
73 public:
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;
77 protected:
78 virtual ~SyncEngineEventListener() {}
81 } // namespace syncer
83 #endif // SYNC_ENGINE_SYNC_ENGINE_EVENT_H_