blob: 50bc551900fb953c4fdd274cd2dc3533f98bbd99 (
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
|
// Copyright 2014 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 "sync/internal_api/public/events/get_updates_response_event.h"
#include "base/strings/stringprintf.h"
#include "sync/protocol/proto_value_conversions.h"
namespace syncer {
GetUpdatesResponseEvent::GetUpdatesResponseEvent(
base::Time timestamp,
const sync_pb::ClientToServerResponse& response,
SyncerError error)
: timestamp_(timestamp),
response_(response),
error_(error) {
}
GetUpdatesResponseEvent::~GetUpdatesResponseEvent() {}
base::Time GetUpdatesResponseEvent::GetTimestamp() const {
return timestamp_;
}
std::string GetUpdatesResponseEvent::GetType() const {
return "GetUpdates Response";
}
std::string GetUpdatesResponseEvent::GetDetails() const {
switch (error_) {
case SYNCER_OK:
return base::StringPrintf("Received %d update(s).",
response_.get_updates().entries_size());
case SERVER_MORE_TO_DOWNLOAD:
return base::StringPrintf("Received %d update(s). Some updates remain.",
response_.get_updates().entries_size());
default:
return base::StringPrintf("Received error: %s",
GetSyncerErrorString(error_));
}
}
scoped_ptr<base::DictionaryValue>
GetUpdatesResponseEvent::GetProtoMessage() const {
return scoped_ptr<base::DictionaryValue>(
ClientToServerResponseToValue(response_, false));
}
scoped_ptr<ProtocolEvent> GetUpdatesResponseEvent::Clone() const {
return scoped_ptr<ProtocolEvent>(
new GetUpdatesResponseEvent(
timestamp_,
response_,
error_));
}
} // namespace syncer
|