Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / sync / internal_api / events / normal_get_updates_request_event.cc
blobf5d6cd4112e24ccdc1fb5808c65f0a9f3703f113
1 // Copyright 2014 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.
5 #include "sync/internal_api/public/events/normal_get_updates_request_event.h"
7 #include "base/strings/stringprintf.h"
8 #include "sync/protocol/proto_value_conversions.h"
9 #include "sync/sessions/nudge_tracker.h"
11 namespace syncer {
13 NormalGetUpdatesRequestEvent::NormalGetUpdatesRequestEvent(
14 base::Time timestamp,
15 const sessions::NudgeTracker& nudge_tracker,
16 const sync_pb::ClientToServerMessage& request)
17 : timestamp_(timestamp),
18 nudged_types_(nudge_tracker.GetNudgedTypes()),
19 notified_types_(nudge_tracker.GetNotifiedTypes()),
20 refresh_requested_types_(nudge_tracker.GetRefreshRequestedTypes()),
21 is_retry_(nudge_tracker.IsRetryRequired()),
22 request_(request) { }
24 NormalGetUpdatesRequestEvent::~NormalGetUpdatesRequestEvent() {}
26 base::Time NormalGetUpdatesRequestEvent::GetTimestamp() const {
27 return timestamp_;
30 std::string NormalGetUpdatesRequestEvent::GetType() const {
31 return "Normal GetUpdate request";
34 std::string NormalGetUpdatesRequestEvent::GetDetails() const {
35 std::string details;
37 if (!nudged_types_.Empty()) {
38 if (!details.empty())
39 details.append("\n");
40 details.append(base::StringPrintf(
41 "Nudged types: %s",
42 ModelTypeSetToString(nudged_types_).c_str()));
45 if (!notified_types_.Empty()) {
46 if (!details.empty())
47 details.append("\n");
48 details.append(base::StringPrintf(
49 "Notified types: %s",
50 ModelTypeSetToString(notified_types_).c_str()));
53 if (!refresh_requested_types_.Empty()) {
54 if (!details.empty())
55 details.append("\n");
56 details.append(base::StringPrintf(
57 "Refresh requested types: %s",
58 ModelTypeSetToString(refresh_requested_types_).c_str()));
61 if (is_retry_) {
62 if (!details.empty())
63 details.append("\n");
64 details.append(base::StringPrintf("Is retry: True"));
67 return details;
70 scoped_ptr<base::DictionaryValue>
71 NormalGetUpdatesRequestEvent::GetProtoMessage() const {
72 return scoped_ptr<base::DictionaryValue>(
73 ClientToServerMessageToValue(request_, false));
76 scoped_ptr<ProtocolEvent> NormalGetUpdatesRequestEvent::Clone() const {
77 return scoped_ptr<ProtocolEvent>(
78 new NormalGetUpdatesRequestEvent(
79 timestamp_,
80 nudged_types_,
81 notified_types_,
82 refresh_requested_types_,
83 is_retry_,
84 request_));
87 NormalGetUpdatesRequestEvent::NormalGetUpdatesRequestEvent(
88 base::Time timestamp,
89 ModelTypeSet nudged_types,
90 ModelTypeSet notified_types,
91 ModelTypeSet refresh_requested_types,
92 bool is_retry,
93 sync_pb::ClientToServerMessage request)
94 : timestamp_(timestamp),
95 nudged_types_(nudged_types),
96 notified_types_(notified_types),
97 refresh_requested_types_(refresh_requested_types),
98 is_retry_(is_retry),
99 request_(request) {}
101 } // namespace