OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_JS_SYNC_MANAGER_OBSERVER_H_ | |
6 #define CHROME_BROWSER_SYNC_JS_SYNC_MANAGER_OBSERVER_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "chrome/browser/sync/engine/syncapi.h" | |
13 #include "chrome/browser/sync/weak_handle.h" | |
14 | |
15 namespace tracked_objects { | |
16 class Location; | |
17 } // namespace tracked_objects | |
18 | |
19 namespace browser_sync { | |
20 | |
21 class JsEventDetails; | |
22 class JsEventHandler; | |
23 | |
24 // Routes SyncManager events to a JsEventHandler. | |
25 class JsSyncManagerObserver : public sync_api::SyncManager::Observer { | |
26 public: | |
27 JsSyncManagerObserver(); | |
28 virtual ~JsSyncManagerObserver(); | |
29 | |
30 void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler); | |
31 | |
32 // sync_api::SyncManager::Observer implementation. | |
33 virtual void OnChangesApplied( | |
34 syncable::ModelType model_type, | |
35 const sync_api::BaseTransaction* trans, | |
36 const sync_api::SyncManager::ChangeRecord* changes, | |
37 int change_count); | |
38 virtual void OnChangesComplete(syncable::ModelType model_type); | |
39 virtual void OnSyncCycleCompleted( | |
40 const sessions::SyncSessionSnapshot* snapshot); | |
41 virtual void OnAuthError(const GoogleServiceAuthError& auth_error); | |
42 virtual void OnUpdatedToken(const std::string& token); | |
43 virtual void OnPassphraseRequired(sync_api::PassphraseRequiredReason reason); | |
44 virtual void OnPassphraseAccepted(const std::string& bootstrap_token); | |
45 virtual void OnEncryptionComplete( | |
46 const syncable::ModelTypeSet& encrypted_types); | |
47 virtual void OnInitializationComplete( | |
48 const WeakHandle<JsBackend>& js_backend); | |
49 virtual void OnStopSyncingPermanently(); | |
50 virtual void OnClearServerDataSucceeded(); | |
51 virtual void OnClearServerDataFailed(); | |
52 virtual void OnMigrationNeededForTypes(const syncable::ModelTypeSet& types); | |
53 | |
54 private: | |
55 void HandleJsEvent(const tracked_objects::Location& from_here, | |
56 const std::string& name, const JsEventDetails& details); | |
57 | |
58 WeakHandle<JsEventHandler> event_handler_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(JsSyncManagerObserver); | |
61 }; | |
62 | |
63 } // namespace browser_sync | |
64 | |
65 #endif // CHROME_BROWSER_SYNC_JS_SYNC_MANAGER_OBSERVER_H_ | |
OLD | NEW |