This source file includes following definitions.
- GetModelAssociator
- type
- StartModels
- CleanUpState
- Observe
- CreateSyncComponents
#include "chrome/browser/sync/glue/session_data_type_controller.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
#include "chrome/browser/sync/glue/synced_window_delegate.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
using content::BrowserThread;
namespace browser_sync {
SessionDataTypeController::SessionDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
Profile* profile,
ProfileSyncService* sync_service)
: FrontendDataTypeController(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
base::Bind(&ChromeReportUnrecoverableError),
profile_sync_factory,
profile,
sync_service) {
}
SessionModelAssociator* SessionDataTypeController::GetModelAssociator() {
return reinterpret_cast<SessionModelAssociator*>(model_associator_.get());
}
syncer::ModelType SessionDataTypeController::type() const {
return syncer::SESSIONS;
}
bool SessionDataTypeController::StartModels() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
std::set<browser_sync::SyncedWindowDelegate*> window =
browser_sync::SyncedWindowDelegate::GetSyncedWindowDelegates();
for (std::set<browser_sync::SyncedWindowDelegate*>::const_iterator i =
window.begin(); i != window.end(); ++i) {
if ((*i)->IsSessionRestoreInProgress()) {
notification_registrar_.Add(
this,
chrome::NOTIFICATION_SESSION_RESTORE_COMPLETE,
content::Source<Profile>(profile_));
return false;
}
}
return true;
}
void SessionDataTypeController::CleanUpState() {
notification_registrar_.RemoveAll();
}
void SessionDataTypeController::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK_EQ(chrome::NOTIFICATION_SESSION_RESTORE_COMPLETE, type);
DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
notification_registrar_.RemoveAll();
OnModelLoaded();
}
SessionDataTypeController::~SessionDataTypeController() {}
void SessionDataTypeController::CreateSyncComponents() {
ProfileSyncComponentsFactory::SyncComponents sync_components =
profile_sync_factory_->CreateSessionSyncComponents(sync_service_, this);
set_model_associator(sync_components.model_associator);
set_change_processor(sync_components.change_processor);
}
}