syncer_command.cc revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2009 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#include "chrome/browser/sync/engine/syncer_command.h" 6 7#include "chrome/browser/sync/engine/net/server_connection_manager.h" 8#include "chrome/browser/sync/sessions/sync_session.h" 9#include "chrome/browser/sync/syncable/directory_manager.h" 10#include "chrome/common/deprecated/event_sys-inl.h" 11 12namespace browser_sync { 13using sessions::SyncSession; 14 15SyncerCommand::SyncerCommand() {} 16SyncerCommand::~SyncerCommand() {} 17 18void SyncerCommand::Execute(SyncSession* session) { 19 ExecuteImpl(session); 20 SendNotifications(session); 21} 22 23void SyncerCommand::SendNotifications(SyncSession* session) { 24 syncable::ScopedDirLookup dir(session->context()->directory_manager(), 25 session->context()->account_name()); 26 if (!dir.good()) { 27 LOG(ERROR) << "Scoped dir lookup failed!"; 28 return; 29 } 30 31 if (session->status_controller()->TestAndClearIsDirty()) { 32 SyncerEvent event(SyncerEvent::STATUS_CHANGED); 33 const sessions::SyncSessionSnapshot& snapshot(session->TakeSnapshot()); 34 event.snapshot = &snapshot; 35 DCHECK(session->context()->syncer_event_channel()); 36 session->context()->syncer_event_channel()->Notify(event); 37 if (session->status_controller()->syncer_status().over_quota) { 38 SyncerEvent quota_event(SyncerEvent::OVER_QUOTA); 39 quota_event.snapshot = &snapshot; 40 session->context()->syncer_event_channel()->Notify(quota_event); 41 } 42 } 43} 44 45} // namespace browser_sync 46