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/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 DictionaryValue
* dict
= new DictionaryValue();
30 dict
->SetString("id", base::Int64ToString(id
));
31 dict
->SetString("location", location_string
);
32 dict
->SetString("writer", WriterTagToString(writer
));
33 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 Value::CreateStringValue(
40 base::Uint64ToString(static_cast<uint64
>(mutations_size
)) +
43 dict
->Set("mutations", mutations_value
);
47 } // namespace syncable