OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sync/engine/build_commit_command.h" | 5 #include "chrome/browser/sync/engine/build_commit_command.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 using syncable::ExtendedAttribute; | 23 using syncable::ExtendedAttribute; |
24 using syncable::Id; | 24 using syncable::Id; |
25 using syncable::MutableEntry; | 25 using syncable::MutableEntry; |
26 using syncable::Name; | 26 using syncable::Name; |
27 | 27 |
28 namespace browser_sync { | 28 namespace browser_sync { |
29 | 29 |
30 BuildCommitCommand::BuildCommitCommand() {} | 30 BuildCommitCommand::BuildCommitCommand() {} |
31 BuildCommitCommand::~BuildCommitCommand() {} | 31 BuildCommitCommand::~BuildCommitCommand() {} |
32 | 32 |
33 void BuildCommitCommand::AddExtensionsActivityToMessage( | |
34 SyncerSession* session, CommitMessage* message) { | |
35 const ExtensionsActivityMonitor::Records& records = | |
36 session->extensions_activity(); | |
37 for (ExtensionsActivityMonitor::Records::const_iterator it = records.begin(); | |
38 it != records.end(); ++it) { | |
39 sync_pb::CommitMessage_ChromiumExtensionsActivity* activity_message = | |
40 message->add_extensions_activity(); | |
41 activity_message->set_extension_id(it->second.extension_id); | |
42 activity_message->set_bookmark_writes_since_last_commit( | |
43 it->second.bookmark_write_count); | |
44 } | |
45 } | |
46 | |
47 void BuildCommitCommand::ExecuteImpl(SyncerSession* session) { | 33 void BuildCommitCommand::ExecuteImpl(SyncerSession* session) { |
48 ClientToServerMessage message; | 34 ClientToServerMessage message; |
49 message.set_share(ToUTF8(session->account_name()).get_string()); | 35 message.set_share(ToUTF8(session->account_name()).get_string()); |
50 message.set_message_contents(ClientToServerMessage::COMMIT); | 36 message.set_message_contents(ClientToServerMessage::COMMIT); |
51 | 37 |
52 CommitMessage* commit_message = message.mutable_commit(); | 38 CommitMessage* commit_message = message.mutable_commit(); |
53 commit_message->set_cache_guid( | 39 commit_message->set_cache_guid( |
54 session->write_transaction()->directory()->cache_guid()); | 40 session->write_transaction()->directory()->cache_guid()); |
55 AddExtensionsActivityToMessage(session, commit_message); | |
56 | 41 |
57 const vector<Id>& commit_ids = session->commit_ids(); | 42 const vector<Id>& commit_ids = session->commit_ids(); |
58 for (size_t i = 0; i < commit_ids.size(); i++) { | 43 for (size_t i = 0; i < commit_ids.size(); i++) { |
59 Id id = commit_ids[i]; | 44 Id id = commit_ids[i]; |
60 SyncEntity* sync_entry = | 45 SyncEntity* sync_entry = |
61 static_cast<SyncEntity*>(commit_message->add_entries()); | 46 static_cast<SyncEntity*>(commit_message->add_entries()); |
62 sync_entry->set_id(id); | 47 sync_entry->set_id(id); |
63 MutableEntry meta_entry(session->write_transaction(), | 48 MutableEntry meta_entry(session->write_transaction(), |
64 syncable::GET_BY_ID, | 49 syncable::GET_BY_ID, |
65 id); | 50 id); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 SyncerProtoUtil::CopyBlobIntoProtoBytes( | 133 SyncerProtoUtil::CopyBlobIntoProtoBytes( |
149 meta_entry.Get(syncable::BOOKMARK_FAVICON), | 134 meta_entry.Get(syncable::BOOKMARK_FAVICON), |
150 bookmark->mutable_bookmark_favicon()); | 135 bookmark->mutable_bookmark_favicon()); |
151 } | 136 } |
152 } | 137 } |
153 } | 138 } |
154 session->set_commit_message(message); | 139 session->set_commit_message(message); |
155 } | 140 } |
156 | 141 |
157 } // namespace browser_sync | 142 } // namespace browser_sync |
OLD | NEW |