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 "base/task/cancelable_task_tracker.h" 14#include "chrome/browser/sync/glue/non_frontend_data_type_controller.h" 15 16class HistoryService; 17 18namespace history { 19class HistoryBackend; 20} 21 22namespace browser_sync { 23 24class ControlTask; 25 26// A class that manages the startup and shutdown of typed_url sync. 27class 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 bool ReadyForStart() const OVERRIDE; 38 39 // Invoked on the history thread to set our history backend - must be called 40 // before CreateSyncComponents() is invoked. 41 void SetBackend(history::HistoryBackend* backend); 42 43 protected: 44 // NonFrontendDataTypeController interface. 45 virtual bool PostTaskOnBackendThread( 46 const tracked_objects::Location& from_here, 47 const base::Closure& task) OVERRIDE; 48 virtual ProfileSyncComponentsFactory::SyncComponents CreateSyncComponents() 49 OVERRIDE; 50 virtual void DisconnectProcessor( 51 sync_driver::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 base::CancelableTaskTracker task_tracker_; 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