Home | History | Annotate | Download | only in notifier
      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 // Interface to the sync notifier, which is an object that receives
      6 // notifications when updates are available for a set of sync types.
      7 // All the observers are notified when such an event happens.
      8 //
      9 // A SyncNotifier must be destroyed on the same thread it was created on,
     10 // and all its methods must be called on the same thread (not necessarily
     11 // the one it was created on). If the methods thread is different from the
     12 // creation thread, then the methods thread must not exist when the SyncNotifier
     13 // is created and destroyed.
     14 //
     15 // In particular, the SyncNotifier will be created on the UI thread, the syncer
     16 // core thread will be created, the SyncNotifier will be used on that core
     17 // thread, the syncer core thread will be destroyed, and then the SyncNotifier
     18 // will be destroyed.
     19 //
     20 // TODO(akalin): Remove the code to deal with this situation once the syncer
     21 // core thread goes away.
     22 
     23 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_H_
     24 #define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_H_
     25 
     26 #include <string>
     27 
     28 #include "chrome/browser/sync/syncable/model_type.h"
     29 
     30 namespace sync_notifier {
     31 class SyncNotifierObserver;
     32 
     33 class SyncNotifier {
     34  public:
     35   SyncNotifier() {}
     36   virtual ~SyncNotifier() {}
     37 
     38   virtual void AddObserver(SyncNotifierObserver* observer) = 0;
     39   virtual void RemoveObserver(SyncNotifierObserver* observer) = 0;
     40 
     41   // SetState must be called once, before any call to UpdateCredentials.
     42   virtual void SetState(const std::string& state) = 0;
     43 
     44   // The observers won't be notified of any notifications until
     45   // UpdateCredentials is called at least once. It can be called more than
     46   // once.
     47   virtual void UpdateCredentials(
     48       const std::string& email, const std::string& token) = 0;
     49 
     50   virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types) = 0;
     51 
     52   // This is here only to support the old p2p notification implementation,
     53   // which is still used by sync integration tests.
     54   // TODO(akalin): Remove this once we move the integration tests off p2p
     55   // notifications.
     56   virtual void SendNotification() = 0;
     57 };
     58 }  // namespace sync_notifier
     59 
     60 #endif  // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_H_
     61 
     62