OLD | NEW |
(Empty) | |
| 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/engine/syncer_session.h" |
| 9 #include "chrome/browser/sync/engine/syncer_status.h" |
| 10 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 11 #include "chrome/browser/sync/util/event_sys-inl.h" |
| 12 #include "chrome/browser/sync/util/sync_types.h" |
| 13 |
| 14 namespace browser_sync { |
| 15 |
| 16 SyncerCommand::SyncerCommand() {} |
| 17 SyncerCommand::~SyncerCommand() {} |
| 18 |
| 19 void SyncerCommand::Execute(SyncerSession *session) { |
| 20 ExecuteImpl(session); |
| 21 SendNotifications(session); |
| 22 } |
| 23 |
| 24 void SyncerCommand::SendNotifications(SyncerSession *session) { |
| 25 syncable::ScopedDirLookup dir(session->dirman(), session->account_name()); |
| 26 if (!dir.good()) { |
| 27 LOG(ERROR) << "Scoped dir lookup failed!"; |
| 28 return; |
| 29 } |
| 30 |
| 31 SyncerStatus status(session); |
| 32 |
| 33 if (status.IsDirty()) { |
| 34 SyncerEvent event = { SyncerEvent::STATUS_CHANGED}; |
| 35 event.last_session = session; |
| 36 session->syncer_event_channel()->NotifyListeners(event); |
| 37 if (status.over_quota()) { |
| 38 SyncerEvent quota_event = {SyncerEvent::OVER_QUOTA}; |
| 39 quota_event.last_session = session; |
| 40 session->syncer_event_channel()->NotifyListeners(quota_event); |
| 41 } |
| 42 status.SetClean(); |
| 43 } |
| 44 if (status.IsAuthDirty()) { |
| 45 ServerConnectionEvent event; |
| 46 event.what_happened = ServerConnectionEvent::STATUS_CHANGED; |
| 47 event.server_reachable = true; |
| 48 event.connection_code = HttpResponse::SYNC_AUTH_ERROR; |
| 49 session->connection_manager()->channel()->NotifyListeners(event); |
| 50 status.SetAuthClean(); |
| 51 } |
| 52 } |
| 53 |
| 54 } // namespace browser_sync |
OLD | NEW |