| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_JS_JS_SYNC_MANAGER_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_JS_JS_SYNC_MANAGER_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_SYNC_JS_JS_SYNC_MANAGER_OBSERVER_H_ | 6 #define CHROME_BROWSER_SYNC_JS_JS_SYNC_MANAGER_OBSERVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/sync/internal_api/sync_manager.h" | 13 #include "chrome/browser/sync/internal_api/sync_manager.h" |
| 13 #include "chrome/browser/sync/protocol/sync_protocol_error.h" | 14 #include "chrome/browser/sync/protocol/sync_protocol_error.h" |
| 14 #include "chrome/browser/sync/util/weak_handle.h" | 15 #include "chrome/browser/sync/util/weak_handle.h" |
| 15 | 16 |
| 16 namespace tracked_objects { | 17 namespace tracked_objects { |
| 17 class Location; | 18 class Location; |
| 18 } // namespace tracked_objects | 19 } // namespace tracked_objects |
| 19 | 20 |
| 20 namespace browser_sync { | 21 namespace browser_sync { |
| 21 | 22 |
| 22 class JsEventDetails; | 23 class JsEventDetails; |
| 23 class JsEventHandler; | 24 class JsEventHandler; |
| 24 | 25 |
| 25 // Routes SyncManager events to a JsEventHandler. | 26 // Routes SyncManager events to a JsEventHandler. |
| 26 class JsSyncManagerObserver : public sync_api::SyncManager::Observer { | 27 class JsSyncManagerObserver : public sync_api::SyncManager::Observer { |
| 27 public: | 28 public: |
| 28 JsSyncManagerObserver(); | 29 JsSyncManagerObserver(); |
| 29 virtual ~JsSyncManagerObserver(); | 30 virtual ~JsSyncManagerObserver(); |
| 30 | 31 |
| 31 void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler); | 32 void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler); |
| 32 | 33 |
| 33 // sync_api::SyncManager::Observer implementation. | 34 // sync_api::SyncManager::Observer implementation. |
| 34 virtual void OnChangesApplied( | 35 virtual void OnChangesApplied( |
| 35 syncable::ModelType model_type, | 36 syncable::ModelType model_type, |
| 36 const sync_api::BaseTransaction* trans, | 37 const sync_api::BaseTransaction* trans, |
| 37 const sync_api::SyncManager::ChangeRecord* changes, | 38 const sync_api::ImmutableChangeRecordList& changes) OVERRIDE; |
| 38 int change_count); | 39 virtual void OnChangesComplete(syncable::ModelType model_type) OVERRIDE; |
| 39 virtual void OnChangesComplete(syncable::ModelType model_type); | |
| 40 virtual void OnSyncCycleCompleted( | 40 virtual void OnSyncCycleCompleted( |
| 41 const sessions::SyncSessionSnapshot* snapshot); | 41 const sessions::SyncSessionSnapshot* snapshot) OVERRIDE; |
| 42 virtual void OnAuthError(const GoogleServiceAuthError& auth_error); | 42 virtual void OnAuthError(const GoogleServiceAuthError& auth_error) OVERRIDE; |
| 43 virtual void OnUpdatedToken(const std::string& token); | 43 virtual void OnUpdatedToken(const std::string& token) OVERRIDE; |
| 44 virtual void OnPassphraseRequired(sync_api::PassphraseRequiredReason reason); | 44 virtual void OnPassphraseRequired( |
| 45 virtual void OnPassphraseAccepted(const std::string& bootstrap_token); | 45 sync_api::PassphraseRequiredReason reason) OVERRIDE; |
| 46 virtual void OnPassphraseAccepted( |
| 47 const std::string& bootstrap_token) OVERRIDE; |
| 46 virtual void OnEncryptionComplete( | 48 virtual void OnEncryptionComplete( |
| 47 const syncable::ModelTypeSet& encrypted_types); | 49 const syncable::ModelTypeSet& encrypted_types) OVERRIDE; |
| 48 virtual void OnInitializationComplete( | 50 virtual void OnInitializationComplete( |
| 49 const WeakHandle<JsBackend>& js_backend, | 51 const WeakHandle<JsBackend>& js_backend, bool success) OVERRIDE; |
| 50 bool success); | 52 virtual void OnStopSyncingPermanently() OVERRIDE; |
| 51 virtual void OnStopSyncingPermanently(); | 53 virtual void OnClearServerDataSucceeded() OVERRIDE; |
| 52 virtual void OnClearServerDataSucceeded(); | 54 virtual void OnClearServerDataFailed() OVERRIDE; |
| 53 virtual void OnClearServerDataFailed(); | |
| 54 virtual void OnMigrationNeededForTypes(const syncable::ModelTypeSet& types); | |
| 55 virtual void OnActionableError( | 55 virtual void OnActionableError( |
| 56 const browser_sync::SyncProtocolError& sync_protocol_error); | 56 const browser_sync::SyncProtocolError& sync_protocol_error) OVERRIDE; |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 void HandleJsEvent(const tracked_objects::Location& from_here, | 59 void HandleJsEvent(const tracked_objects::Location& from_here, |
| 60 const std::string& name, const JsEventDetails& details); | 60 const std::string& name, const JsEventDetails& details); |
| 61 | 61 |
| 62 WeakHandle<JsEventHandler> event_handler_; | 62 WeakHandle<JsEventHandler> event_handler_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(JsSyncManagerObserver); | 64 DISALLOW_COPY_AND_ASSIGN(JsSyncManagerObserver); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace browser_sync | 67 } // namespace browser_sync |
| 68 | 68 |
| 69 #endif // CHROME_BROWSER_SYNC_JS_JS_SYNC_MANAGER_OBSERVER_H_ | 69 #endif // CHROME_BROWSER_SYNC_JS_JS_SYNC_MANAGER_OBSERVER_H_ |
| OLD | NEW |