Home | History | Annotate | Download | only in internal_api
      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.
      4 
      5 #ifndef SYNC_INTERNAL_API_JS_SYNC_MANAGER_OBSERVER_H_
      6 #define SYNC_INTERNAL_API_JS_SYNC_MANAGER_OBSERVER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/compiler_specific.h"
     12 #include "sync/base/sync_export.h"
     13 #include "sync/internal_api/public/sync_manager.h"
     14 #include "sync/internal_api/public/util/weak_handle.h"
     15 #include "sync/protocol/sync_protocol_error.h"
     16 
     17 namespace tracked_objects {
     18 class Location;
     19 }  // namespace tracked_objects
     20 
     21 namespace syncer {
     22 
     23 class JsEventDetails;
     24 class JsEventHandler;
     25 
     26 // Routes SyncManager events to a JsEventHandler.
     27 class SYNC_EXPORT_PRIVATE JsSyncManagerObserver : public SyncManager::Observer {
     28  public:
     29   JsSyncManagerObserver();
     30   virtual ~JsSyncManagerObserver();
     31 
     32   void SetJsEventHandler(const WeakHandle<JsEventHandler>& event_handler);
     33 
     34   // SyncManager::Observer implementation.
     35   virtual void OnSyncCycleCompleted(
     36       const sessions::SyncSessionSnapshot& snapshot) OVERRIDE;
     37   virtual void OnConnectionStatusChange(ConnectionStatus status) OVERRIDE;
     38   virtual void OnUpdatedToken(const std::string& token) OVERRIDE;
     39   virtual void OnInitializationComplete(
     40       const WeakHandle<JsBackend>& js_backend,
     41       const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener,
     42       bool success,
     43       syncer::ModelTypeSet restored_types) OVERRIDE;
     44   virtual void OnStopSyncingPermanently() OVERRIDE;
     45   virtual void OnActionableError(
     46       const SyncProtocolError& sync_protocol_error) OVERRIDE;
     47 
     48  private:
     49   void HandleJsEvent(const tracked_objects::Location& from_here,
     50                     const std::string& name, const JsEventDetails& details);
     51 
     52   WeakHandle<JsEventHandler> event_handler_;
     53 
     54   DISALLOW_COPY_AND_ASSIGN(JsSyncManagerObserver);
     55 };
     56 
     57 }  // namespace syncer
     58 
     59 #endif  // SYNC_INTERNAL_API_JS_SYNC_MANAGER_OBSERVER_H_
     60