OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-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/download_updates_command.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "chrome/browser/sync/engine/syncer.h" |
| 10 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 11 #include "chrome/browser/sync/engine/syncproto.h" |
| 12 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 13 #include "chrome/browser/sync/util/character_set_converters.h" |
| 14 #include "chrome/browser/sync/util/sync_types.h" |
| 15 |
| 16 using syncable::ScopedDirLookup; |
| 17 |
| 18 namespace browser_sync { |
| 19 |
| 20 using std::string; |
| 21 |
| 22 DownloadUpdatesCommand::DownloadUpdatesCommand() {} |
| 23 DownloadUpdatesCommand::~DownloadUpdatesCommand() {} |
| 24 |
| 25 void DownloadUpdatesCommand::ExecuteImpl(SyncerSession *session) { |
| 26 ClientToServerMessage client_to_server_message; |
| 27 ClientToServerResponse update_response; |
| 28 |
| 29 client_to_server_message.set_share( |
| 30 static_cast<const string&>(ToUTF8(session->account_name()))); |
| 31 client_to_server_message.set_message_contents( |
| 32 ClientToServerMessage::GET_UPDATES); |
| 33 GetUpdatesMessage* get_updates = |
| 34 client_to_server_message.mutable_get_updates(); |
| 35 |
| 36 ScopedDirLookup dir(session->dirman(), session->account_name()); |
| 37 if (!dir.good()) { |
| 38 LOG(ERROR) << "Scoped dir lookup failed!"; |
| 39 return; |
| 40 } |
| 41 LOG(INFO) << "Getting updates from ts " << dir->last_sync_timestamp(); |
| 42 get_updates->set_from_timestamp(dir->last_sync_timestamp()); |
| 43 |
| 44 // Set GetUpdatesMessage.GetUpdatesCallerInfo information. |
| 45 get_updates->mutable_caller_info()->set_source(session->TestAndSetSource()); |
| 46 get_updates->mutable_caller_info()->set_notifications_enabled( |
| 47 session->notifications_enabled()); |
| 48 |
| 49 bool ok = SyncerProtoUtil::PostClientToServerMessage( |
| 50 &client_to_server_message, |
| 51 &update_response, |
| 52 session); |
| 53 |
| 54 if (!ok) { |
| 55 SyncerStatus status(session); |
| 56 status.increment_consecutive_problem_get_updates(); |
| 57 status.increment_consecutive_errors(); |
| 58 LOG(ERROR) << "PostClientToServerMessage() failed"; |
| 59 return; |
| 60 } |
| 61 session->set_update_response(update_response); |
| 62 } |
| 63 |
| 64 } // namespace browser_sync |
OLD | NEW |