Roll src/third_party/WebKit 96fb88b:6bbd108 (svn 201045:201047)
[chromium-blink-merge.git] / sync / internal_api / public / sessions / commit_counters.cc
blob6038ad29d9e62f3f7066765207ffe5f2a862a7f6
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"
10 namespace syncer {
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);
26 return value.Pass();
29 std::string CommitCounters::ToString() const {
30 std::string result;
31 scoped_ptr<base::DictionaryValue> value = ToValue();
32 JSONStringValueSerializer serializer(&result);
33 serializer.Serialize(*value);
34 return result;
37 } // namespace syncer