diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 19:32:28 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 19:32:28 +0000 |
commit | 90ce61b5448c93e52a34b71535d86605a4f7f90d (patch) | |
tree | 357c076b80e6bf248511878c8cde5b262466158f /sync/engine/sync_engine_event.h | |
parent | 7500c55e2fc2219e50e3b6b40e6c8e3ed3820d20 (diff) | |
download | chromium_src-90ce61b5448c93e52a34b71535d86605a4f7f90d.zip chromium_src-90ce61b5448c93e52a34b71535d86605a4f7f90d.tar.gz chromium_src-90ce61b5448c93e52a34b71535d86605a4f7f90d.tar.bz2 |
[Sync] Convert SyncSessionSnapshot to a copy-able class.
Previously it was an immutable struct that was passed around by making
dynamic allocations and passing pointers. We now just have a class with
only getters and no setters, but support for default copy and assign.
This cleans up some code and makes some future work easier to pass snapshots
around.
BUG=none
TEST=sync_unit_tests
Review URL: http://codereview.chromium.org/10197004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine/sync_engine_event.h')
-rw-r--r-- | sync/engine/sync_engine_event.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/sync/engine/sync_engine_event.h b/sync/engine/sync_engine_event.h new file mode 100644 index 0000000..54990d2 --- /dev/null +++ b/sync/engine/sync_engine_event.h @@ -0,0 +1,78 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ +#define SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ +#pragma once + +#include <string> + +#include "base/observer_list.h" +#include "sync/sessions/session_state.h" +#include "sync/syncable/model_type.h" + +namespace syncable { +class Id; +} + +namespace browser_sync { + +struct SyncEngineEvent { + enum EventCause { + //////////////////////////////////////////////////////////////// + // Sent on entry of Syncer state machine + SYNC_CYCLE_BEGIN, + + // SyncerCommand generated events. + STATUS_CHANGED, + + // We have reached the SYNCER_END state in the main sync loop. + SYNC_CYCLE_ENDED, + + //////////////////////////////////////////////////////////////// + // Generated in response to specific protocol actions or events. + + // New token in updated_token. + UPDATED_TOKEN, + + // This is sent after the Syncer (and SyncerThread) have initiated self + // halt due to no longer being permitted to communicate with the server. + // The listener should sever the sync / browser connections and delete sync + // data (i.e. as if the user clicked 'Stop Syncing' in the browser. + STOP_SYNCING_PERMANENTLY, + + // These events are sent to indicate when we know the clearing of + // server data have failed or succeeded. + CLEAR_SERVER_DATA_SUCCEEDED, + CLEAR_SERVER_DATA_FAILED, + + // This event is sent when we receive an actionable error. It is upto + // the listeners to figure out the action to take using the snapshot sent. + ACTIONABLE_ERROR, + }; + + explicit SyncEngineEvent(EventCause cause); + ~SyncEngineEvent(); + + EventCause what_happened; + + // The last session used for syncing. + sessions::SyncSessionSnapshot snapshot; + + // Update-Client-Auth returns a new token for sync use. + std::string updated_token; +}; + +class SyncEngineEventListener { + public: + // TODO(tim): Consider splitting this up to multiple callbacks, rather than + // have to do Event e(type); OnSyncEngineEvent(e); at all callsites, + virtual void OnSyncEngineEvent(const SyncEngineEvent& event) = 0; + protected: + virtual ~SyncEngineEventListener() {} +}; + +} // namespace browser_sync + +#endif // SYNC_ENGINE_SYNC_ENGINE_EVENT_H_ |