| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "sync/internal_api/public/events/get_updates_response_event.h" | |
| 6 | |
| 7 #include "base/strings/stringprintf.h" | |
| 8 #include "sync/protocol/proto_value_conversions.h" | |
| 9 | |
| 10 namespace syncer { | |
| 11 | |
| 12 GetUpdatesResponseEvent::GetUpdatesResponseEvent( | |
| 13 base::Time timestamp, | |
| 14 const sync_pb::ClientToServerResponse& response, | |
| 15 SyncerError error) | |
| 16 : timestamp_(timestamp), | |
| 17 response_(response), | |
| 18 error_(error) { | |
| 19 } | |
| 20 | |
| 21 GetUpdatesResponseEvent::~GetUpdatesResponseEvent() {} | |
| 22 | |
| 23 base::Time GetUpdatesResponseEvent::GetTimestamp() const { | |
| 24 return timestamp_; | |
| 25 } | |
| 26 | |
| 27 std::string GetUpdatesResponseEvent::GetType() const { | |
| 28 return "GetUpdates Response"; | |
| 29 } | |
| 30 | |
| 31 std::string GetUpdatesResponseEvent::GetDetails() const { | |
| 32 switch (error_) { | |
| 33 case SYNCER_OK: | |
| 34 return base::StringPrintf("Received %d update(s).", | |
| 35 response_.get_updates().entries_size()); | |
| 36 case SERVER_MORE_TO_DOWNLOAD: | |
| 37 return base::StringPrintf("Received %d update(s). Some updates remain.", | |
| 38 response_.get_updates().entries_size()); | |
| 39 default: | |
| 40 return base::StringPrintf("Received error: %s", | |
| 41 GetSyncerErrorString(error_)); | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 std::unique_ptr<base::DictionaryValue> | |
| 46 GetUpdatesResponseEvent::GetProtoMessage() const { | |
| 47 return std::unique_ptr<base::DictionaryValue>( | |
| 48 ClientToServerResponseToValue(response_, false)); | |
| 49 } | |
| 50 | |
| 51 std::unique_ptr<ProtocolEvent> GetUpdatesResponseEvent::Clone() const { | |
| 52 return std::unique_ptr<ProtocolEvent>( | |
| 53 new GetUpdatesResponseEvent(timestamp_, response_, error_)); | |
| 54 } | |
| 55 | |
| 56 } // namespace syncer | |
| OLD | NEW |