• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "sync/internal_api/public/events/commit_request_event.h"
6 
7 #include "base/format_macros.h"
8 #include "base/strings/stringprintf.h"
9 #include "sync/protocol/proto_value_conversions.h"
10 
11 namespace syncer {
12 
CommitRequestEvent(base::Time timestamp,size_t num_items,ModelTypeSet contributing_types_,const sync_pb::ClientToServerMessage & request)13 CommitRequestEvent::CommitRequestEvent(
14     base::Time timestamp,
15     size_t num_items,
16     ModelTypeSet contributing_types_,
17     const sync_pb::ClientToServerMessage& request)
18   : timestamp_(timestamp),
19     num_items_(num_items),
20     contributing_types_(contributing_types_),
21     request_(request) {}
22 
~CommitRequestEvent()23 CommitRequestEvent::~CommitRequestEvent() {}
24 
GetTimestamp() const25 base::Time CommitRequestEvent::GetTimestamp() const {
26   return timestamp_;
27 }
28 
GetType() const29 std::string CommitRequestEvent::GetType() const {
30   return "Commit Request";
31 }
32 
GetDetails() const33 std::string CommitRequestEvent::GetDetails() const {
34   return base::StringPrintf(
35       "Item count: %" PRIuS "\n"
36       "Contributing types: %s",
37       num_items_,
38       ModelTypeSetToString(contributing_types_).c_str());
39 }
40 
GetProtoMessage() const41 scoped_ptr<base::DictionaryValue> CommitRequestEvent::GetProtoMessage() const {
42   return scoped_ptr<base::DictionaryValue>(
43       ClientToServerMessageToValue(request_, false));
44 }
45 
Clone() const46 scoped_ptr<ProtocolEvent> CommitRequestEvent::Clone() const {
47   return scoped_ptr<ProtocolEvent>(
48       new CommitRequestEvent(timestamp_,
49                              num_items_,
50                              contributing_types_,
51                              request_));
52 }
53 
54 }  // namespace syncer
55