blob: 1883e315612bd0b4186f15997f63aa88657e88ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/sync/engine/download_updates_command.h"
#include <string>
#include "chrome/browser/sync/engine/syncer.h"
#include "chrome/browser/sync/engine/syncer_proto_util.h"
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/util/sync_types.h"
using syncable::ScopedDirLookup;
namespace browser_sync {
using std::string;
DownloadUpdatesCommand::DownloadUpdatesCommand() {}
DownloadUpdatesCommand::~DownloadUpdatesCommand() {}
void DownloadUpdatesCommand::ExecuteImpl(SyncerSession* session) {
ClientToServerMessage client_to_server_message;
ClientToServerResponse update_response;
client_to_server_message.set_share(session->account_name());
client_to_server_message.set_message_contents(
ClientToServerMessage::GET_UPDATES);
GetUpdatesMessage* get_updates =
client_to_server_message.mutable_get_updates();
ScopedDirLookup dir(session->dirman(), session->account_name());
if (!dir.good()) {
LOG(ERROR) << "Scoped dir lookup failed!";
return;
}
LOG(INFO) << "Getting updates from ts " << dir->last_sync_timestamp();
get_updates->set_from_timestamp(dir->last_sync_timestamp());
// Set GetUpdatesMessage.GetUpdatesCallerInfo information.
get_updates->mutable_caller_info()->set_source(session->TestAndSetSource());
get_updates->mutable_caller_info()->set_notifications_enabled(
session->notifications_enabled());
bool ok = SyncerProtoUtil::PostClientToServerMessage(
&client_to_server_message,
&update_response,
session);
if (!ok) {
SyncerStatus status(session);
status.increment_consecutive_problem_get_updates();
status.increment_consecutive_errors();
LOG(ERROR) << "PostClientToServerMessage() failed";
return;
}
session->set_update_response(update_response);
}
} // namespace browser_sync
|