Roll src/third_party/WebKit 96fb88b:6bbd108 (svn 201045:201047)
[chromium-blink-merge.git] / sync / internal_api / public / sessions / update_counters.cc
blob0656bafa1fae0abffae950069f2bb9946bc5a040
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/sessions/update_counters.h"
7 #include "base/json/json_string_value_serializer.h"
8 #include "base/values.h"
10 namespace syncer {
12 UpdateCounters::UpdateCounters()
13 : num_updates_received(0),
14 num_reflected_updates_received(0),
15 num_tombstone_updates_received(0),
16 num_updates_applied(0),
17 num_hierarchy_conflict_application_failures(0),
18 num_encryption_conflict_application_failures(0),
19 num_server_overwrites(0),
20 num_local_overwrites(0) {}
22 UpdateCounters::~UpdateCounters() {}
24 scoped_ptr<base::DictionaryValue> UpdateCounters::ToValue() const {
25 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
27 value->SetInteger("numUpdatesReceived", num_updates_received);
28 value->SetInteger("numReflectedUpdatesReceived",
29 num_reflected_updates_received);
30 value->SetInteger("numTombstoneUpdatesReceived",
31 num_tombstone_updates_received);
33 value->SetInteger("numUpdatesApplied", num_updates_applied);
34 value->SetInteger("numHierarchyConflictApplicationFailures",
35 num_hierarchy_conflict_application_failures);
36 value->SetInteger("numEncryptionConflictApplicationFailures",
37 num_encryption_conflict_application_failures);
39 value->SetInteger("numServerOverwrites", num_server_overwrites);
40 value->SetInteger("numLocalOverwrites", num_local_overwrites);
42 return value.Pass();
45 std::string UpdateCounters::ToString() const {
46 std::string result;
47 scoped_ptr<base::DictionaryValue> value = ToValue();
48 JSONStringValueSerializer serializer(&result);
49 serializer.Serialize(*value);
50 return result;
53 } // namespace syncer