This source file includes following definitions.
- StartModels
- OnTemplateURLServiceLoaded
#include "chrome/browser/sync/glue/search_engine_data_type_controller.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "content/public/browser/browser_thread.h"
#include "sync/api/syncable_service.h"
using content::BrowserThread;
namespace browser_sync {
SearchEngineDataTypeController::SearchEngineDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
Profile* profile,
ProfileSyncService* sync_service)
: UIDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
syncer::SEARCH_ENGINES,
profile_sync_factory,
profile,
sync_service) {
}
SearchEngineDataTypeController::~SearchEngineDataTypeController() {}
bool SearchEngineDataTypeController::StartModels() {
TemplateURLService* turl_service =
TemplateURLServiceFactory::GetForProfile(profile_);
DCHECK(turl_service);
turl_service->Load();
if (turl_service->loaded()) {
return true;
}
template_url_subscription_ = turl_service->RegisterOnLoadedCallback(
base::Bind(&SearchEngineDataTypeController::OnTemplateURLServiceLoaded,
this));
return false;
}
void SearchEngineDataTypeController::OnTemplateURLServiceLoaded() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(state_, MODEL_STARTING);
template_url_subscription_.reset();
OnModelLoaded();
}
}