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/sessions/commit_counters.h" | |
6 | |
7 #include "base/json/json_string_value_serializer.h" | |
8 #include "base/values.h" | |
9 | |
10 namespace syncer { | |
11 | |
12 CommitCounters::CommitCounters() | |
13 : num_commits_attempted(0), | |
14 num_commits_success(0), | |
15 num_commits_conflict(0), | |
16 num_commits_error(0) {} | |
17 | |
18 CommitCounters::~CommitCounters() {} | |
19 | |
20 std::unique_ptr<base::DictionaryValue> CommitCounters::ToValue() const { | |
21 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | |
22 value->SetInteger("numCommitsAttempted", num_commits_attempted); | |
23 value->SetInteger("numCommitsSuccess", num_commits_success); | |
24 value->SetInteger("numCommitsConflict", num_commits_conflict); | |
25 value->SetInteger("numCommitsError", num_commits_error); | |
26 return value; | |
27 } | |
28 | |
29 std::string CommitCounters::ToString() const { | |
30 std::string result; | |
31 std::unique_ptr<base::DictionaryValue> value = ToValue(); | |
32 JSONStringValueSerializer serializer(&result); | |
33 serializer.Serialize(*value); | |
34 return result; | |
35 } | |
36 | |
37 } // namespace syncer | |
OLD | NEW |