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/commit_counters.h"
7 #include "base/json/json_string_value_serializer.h"
8 #include "base/values.h"
12 CommitCounters::CommitCounters()
13 : num_commits_attempted(0),
14 num_commits_success(0),
15 num_commits_conflict(0),
16 num_commits_error(0) {}
18 CommitCounters::~CommitCounters() {}
20 scoped_ptr
<base::DictionaryValue
> CommitCounters::ToValue() const {
21 scoped_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
);
29 std::string
CommitCounters::ToString() const {
31 scoped_ptr
<base::DictionaryValue
> value
= ToValue();
32 JSONStringValueSerializer
serializer(&result
);
33 serializer
.Serialize(*value
);