OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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. |
| 4 |
| 5 #ifndef SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ |
| 6 #define SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "base/observer_list.h" |
| 12 #include "sync/sessions/session_state.h" |
| 13 #include "sync/syncable/model_type.h" |
| 14 |
| 15 namespace syncable { |
| 16 class Id; |
| 17 } |
| 18 |
| 19 namespace browser_sync { |
| 20 |
| 21 struct SyncEngineEvent { |
| 22 enum EventCause { |
| 23 //////////////////////////////////////////////////////////////// |
| 24 // Sent on entry of Syncer state machine |
| 25 SYNC_CYCLE_BEGIN, |
| 26 |
| 27 // SyncerCommand generated events. |
| 28 STATUS_CHANGED, |
| 29 |
| 30 // We have reached the SYNCER_END state in the main sync loop. |
| 31 SYNC_CYCLE_ENDED, |
| 32 |
| 33 //////////////////////////////////////////////////////////////// |
| 34 // Generated in response to specific protocol actions or events. |
| 35 |
| 36 // New token in updated_token. |
| 37 UPDATED_TOKEN, |
| 38 |
| 39 // This is sent after the Syncer (and SyncerThread) have initiated self |
| 40 // halt due to no longer being permitted to communicate with the server. |
| 41 // The listener should sever the sync / browser connections and delete sync |
| 42 // data (i.e. as if the user clicked 'Stop Syncing' in the browser. |
| 43 STOP_SYNCING_PERMANENTLY, |
| 44 |
| 45 // These events are sent to indicate when we know the clearing of |
| 46 // server data have failed or succeeded. |
| 47 CLEAR_SERVER_DATA_SUCCEEDED, |
| 48 CLEAR_SERVER_DATA_FAILED, |
| 49 |
| 50 // This event is sent when we receive an actionable error. It is upto |
| 51 // the listeners to figure out the action to take using the snapshot sent. |
| 52 ACTIONABLE_ERROR, |
| 53 }; |
| 54 |
| 55 explicit SyncEngineEvent(EventCause cause); |
| 56 ~SyncEngineEvent(); |
| 57 |
| 58 EventCause what_happened; |
| 59 |
| 60 // The last session used for syncing. |
| 61 sessions::SyncSessionSnapshot snapshot; |
| 62 |
| 63 // Update-Client-Auth returns a new token for sync use. |
| 64 std::string updated_token; |
| 65 }; |
| 66 |
| 67 class SyncEngineEventListener { |
| 68 public: |
| 69 // TODO(tim): Consider splitting this up to multiple callbacks, rather than |
| 70 // have to do Event e(type); OnSyncEngineEvent(e); at all callsites, |
| 71 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) = 0; |
| 72 protected: |
| 73 virtual ~SyncEngineEventListener() {} |
| 74 }; |
| 75 |
| 76 } // namespace browser_sync |
| 77 |
| 78 #endif // SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ |
OLD | NEW |