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"
12 WriteTransactionInfo::WriteTransactionInfo(
14 tracked_objects::Location location
,
16 ImmutableEntryKernelMutationMap mutations
)
18 location_string(location
.ToString()),
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());
39 new base::StringValue(
40 base::SizeTToString(mutations_size
) + " mutations");
42 dict
->Set("mutations", mutations_value
);
46 } // namespace syncable