Home | History | Annotate | Download | only in glue
      1 // Copyright (c) 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 CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__
      6 #define CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__
      7 
      8 #include <string>
      9 
     10 #include "base/compiler_specific.h"
     11 #include "base/memory/ref_counted.h"
     12 #include "base/prefs/pref_change_registrar.h"
     13 #include "chrome/browser/common/cancelable_request.h"
     14 #include "chrome/browser/sync/glue/non_frontend_data_type_controller.h"
     15 
     16 class HistoryService;
     17 
     18 namespace history {
     19 class HistoryBackend;
     20 }
     21 
     22 namespace browser_sync {
     23 
     24 class ControlTask;
     25 
     26 // A class that manages the startup and shutdown of typed_url sync.
     27 class TypedUrlDataTypeController : public NonFrontendDataTypeController {
     28  public:
     29   TypedUrlDataTypeController(
     30       ProfileSyncComponentsFactory* profile_sync_factory,
     31       Profile* profile,
     32       ProfileSyncService* sync_service);
     33 
     34   // NonFrontendDataTypeController implementation
     35   virtual syncer::ModelType type() const OVERRIDE;
     36   virtual syncer::ModelSafeGroup model_safe_group() const OVERRIDE;
     37   virtual void LoadModels(const ModelLoadCallback& model_load_callback)
     38       OVERRIDE;
     39 
     40   // Invoked on the history thread to set our history backend - must be called
     41   // before CreateSyncComponents() is invoked.
     42   void SetBackend(history::HistoryBackend* backend);
     43 
     44  protected:
     45   // NonFrontendDataTypeController interface.
     46   virtual bool PostTaskOnBackendThread(
     47       const tracked_objects::Location& from_here,
     48       const base::Closure& task) OVERRIDE;
     49   virtual ProfileSyncComponentsFactory::SyncComponents CreateSyncComponents()
     50       OVERRIDE;
     51   virtual void DisconnectProcessor(ChangeProcessor* processor) OVERRIDE;
     52 
     53  private:
     54   virtual ~TypedUrlDataTypeController();
     55 
     56   void OnSavingBrowserHistoryDisabledChanged();
     57 
     58   history::HistoryBackend* backend_;
     59   PrefChangeRegistrar pref_registrar_;
     60 
     61   // Helper object to make sure we don't leave tasks running on the history
     62   // thread.
     63   CancelableRequestConsumerT<int, 0> cancelable_consumer_;
     64 
     65   DISALLOW_COPY_AND_ASSIGN(TypedUrlDataTypeController);
     66 };
     67 
     68 }  // namespace browser_sync
     69 
     70 #endif  // CHROME_BROWSER_SYNC_GLUE_TYPED_URL_DATA_TYPE_CONTROLLER_H__
     71