OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/sync/engine/cycle/commit_counters.h" | 5 #include "components/sync/engine/cycle/commit_counters.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/values.h" | |
9 | 8 |
10 namespace syncer { | 9 namespace syncer { |
11 | 10 |
12 CommitCounters::CommitCounters() | 11 CommitCounters::CommitCounters() |
13 : num_commits_attempted(0), | 12 : num_commits_attempted(0), |
14 num_commits_success(0), | 13 num_commits_success(0), |
15 num_commits_conflict(0), | 14 num_commits_conflict(0), |
16 num_commits_error(0) {} | 15 num_commits_error(0) {} |
17 | 16 |
18 CommitCounters::~CommitCounters() {} | 17 CommitCounters::~CommitCounters() {} |
19 | 18 |
20 std::unique_ptr<base::DictionaryValue> CommitCounters::ToValue() const { | 19 std::unique_ptr<base::DictionaryValue> CommitCounters::ToValue() const { |
21 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 20 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
22 value->SetInteger("numCommitsAttempted", num_commits_attempted); | 21 value->SetInteger("numCommitsAttempted", num_commits_attempted); |
23 value->SetInteger("numCommitsSuccess", num_commits_success); | 22 value->SetInteger("numCommitsSuccess", num_commits_success); |
24 value->SetInteger("numCommitsConflict", num_commits_conflict); | 23 value->SetInteger("numCommitsConflict", num_commits_conflict); |
25 value->SetInteger("numCommitsError", num_commits_error); | 24 value->SetInteger("numCommitsError", num_commits_error); |
26 return value; | 25 return value; |
27 } | 26 } |
28 | 27 |
29 std::string CommitCounters::ToString() const { | 28 std::string CommitCounters::ToString() const { |
30 std::string result; | 29 std::string result; |
31 std::unique_ptr<base::DictionaryValue> value = ToValue(); | 30 std::unique_ptr<base::DictionaryValue> value = ToValue(); |
32 JSONStringValueSerializer serializer(&result); | 31 JSONStringValueSerializer serializer(&result); |
33 serializer.Serialize(*value); | 32 serializer.Serialize(*value); |
34 return result; | 33 return result; |
35 } | 34 } |
36 | 35 |
37 } // namespace syncer | 36 } // namespace syncer |
OLD | NEW |