Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / sync / syncable / write_transaction_info.cc
bloba8a23271db583bc9772f3f9b923d12eeda51a9c8
1 // Copyright (c) 2012 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/syncable/write_transaction_info.h"
7 #include "base/strings/string_number_conversions.h"
9 namespace syncer {
10 namespace syncable {
12 WriteTransactionInfo::WriteTransactionInfo(
13 int64 id,
14 tracked_objects::Location location,
15 WriterTag writer,
16 ImmutableEntryKernelMutationMap mutations)
17 : id(id),
18 location_string(location.ToString()),
19 writer(writer),
20 mutations(mutations) {}
22 WriteTransactionInfo::WriteTransactionInfo()
23 : id(-1), writer(INVALID) {}
25 WriteTransactionInfo::~WriteTransactionInfo() {}
27 base::DictionaryValue* WriteTransactionInfo::ToValue(
28 size_t max_mutations_size) const {
29 base::DictionaryValue* dict = new base::DictionaryValue();
30 dict->SetString("id", base::Int64ToString(id));
31 dict->SetString("location", location_string);
32 dict->SetString("writer", WriterTagToString(writer));
33 base::Value* mutations_value = NULL;
34 const size_t mutations_size = mutations.Get().size();
35 if (mutations_size <= max_mutations_size) {
36 mutations_value = EntryKernelMutationMapToValue(mutations.Get());
37 } else {
38 mutations_value =
39 new base::StringValue(
40 base::SizeTToString(mutations_size) + " mutations");
42 dict->Set("mutations", mutations_value);
43 return dict;
46 } // namespace syncable
47 } // namespace syncer