| 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 |
| 11 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 11 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
| 12 #include "chrome/browser/sync/engine/syncer_session.h" | |
| 13 #include "chrome/browser/sync/engine/syncer_util.h" | 12 #include "chrome/browser/sync/engine/syncer_util.h" |
| 14 #include "chrome/browser/sync/engine/syncproto.h" | 13 #include "chrome/browser/sync/sessions/sync_session.h" |
| 15 #include "chrome/browser/sync/syncable/syncable.h" | 14 #include "chrome/browser/sync/syncable/syncable.h" |
| 16 #include "chrome/browser/sync/syncable/syncable_changes_version.h" | 15 #include "chrome/browser/sync/syncable/syncable_changes_version.h" |
| 17 #include "chrome/browser/sync/util/sync_types.h" | 16 #include "chrome/browser/sync/util/sync_types.h" |
| 18 | 17 |
| 19 using std::set; | 18 using std::set; |
| 20 using std::string; | 19 using std::string; |
| 21 using std::vector; | 20 using std::vector; |
| 22 using syncable::ExtendedAttribute; | 21 using syncable::ExtendedAttribute; |
| 23 using syncable::Id; | 22 using syncable::Id; |
| 24 using syncable::MutableEntry; | 23 using syncable::MutableEntry; |
| 25 | 24 |
| 26 namespace browser_sync { | 25 namespace browser_sync { |
| 27 | 26 |
| 27 using sessions::SyncSession; |
| 28 |
| 28 BuildCommitCommand::BuildCommitCommand() {} | 29 BuildCommitCommand::BuildCommitCommand() {} |
| 29 BuildCommitCommand::~BuildCommitCommand() {} | 30 BuildCommitCommand::~BuildCommitCommand() {} |
| 30 | 31 |
| 31 void BuildCommitCommand::AddExtensionsActivityToMessage( | 32 void BuildCommitCommand::AddExtensionsActivityToMessage( |
| 32 SyncerSession* session, CommitMessage* message) { | 33 SyncSession* session, CommitMessage* message) { |
| 33 const ExtensionsActivityMonitor::Records& records = | 34 const ExtensionsActivityMonitor::Records& records = |
| 34 session->extensions_activity(); | 35 session->extensions_activity(); |
| 35 for (ExtensionsActivityMonitor::Records::const_iterator it = records.begin(); | 36 for (ExtensionsActivityMonitor::Records::const_iterator it = records.begin(); |
| 36 it != records.end(); ++it) { | 37 it != records.end(); ++it) { |
| 37 sync_pb::CommitMessage_ChromiumExtensionsActivity* activity_message = | 38 sync_pb::CommitMessage_ChromiumExtensionsActivity* activity_message = |
| 38 message->add_extensions_activity(); | 39 message->add_extensions_activity(); |
| 39 activity_message->set_extension_id(it->second.extension_id); | 40 activity_message->set_extension_id(it->second.extension_id); |
| 40 activity_message->set_bookmark_writes_since_last_commit( | 41 activity_message->set_bookmark_writes_since_last_commit( |
| 41 it->second.bookmark_write_count); | 42 it->second.bookmark_write_count); |
| 42 } | 43 } |
| 43 } | 44 } |
| 44 | 45 |
| 45 void BuildCommitCommand::ExecuteImpl(SyncerSession* session) { | 46 void BuildCommitCommand::ExecuteImpl(SyncSession* session) { |
| 46 ClientToServerMessage message; | 47 ClientToServerMessage message; |
| 47 message.set_share(session->account_name()); | 48 message.set_share(session->context()->account_name()); |
| 48 message.set_message_contents(ClientToServerMessage::COMMIT); | 49 message.set_message_contents(ClientToServerMessage::COMMIT); |
| 49 | 50 |
| 50 CommitMessage* commit_message = message.mutable_commit(); | 51 CommitMessage* commit_message = message.mutable_commit(); |
| 51 commit_message->set_cache_guid( | 52 commit_message->set_cache_guid( |
| 52 session->write_transaction()->directory()->cache_guid()); | 53 session->write_transaction()->directory()->cache_guid()); |
| 53 AddExtensionsActivityToMessage(session, commit_message); | 54 AddExtensionsActivityToMessage(session, commit_message); |
| 54 | 55 |
| 55 const vector<Id>& commit_ids = session->commit_ids(); | 56 const vector<Id>& commit_ids = session->status_controller()->commit_ids(); |
| 56 for (size_t i = 0; i < commit_ids.size(); i++) { | 57 for (size_t i = 0; i < commit_ids.size(); i++) { |
| 57 Id id = commit_ids[i]; | 58 Id id = commit_ids[i]; |
| 58 SyncEntity* sync_entry = | 59 SyncEntity* sync_entry = |
| 59 static_cast<SyncEntity*>(commit_message->add_entries()); | 60 static_cast<SyncEntity*>(commit_message->add_entries()); |
| 60 sync_entry->set_id(id); | 61 sync_entry->set_id(id); |
| 61 MutableEntry meta_entry(session->write_transaction(), | 62 MutableEntry meta_entry(session->write_transaction(), |
| 62 syncable::GET_BY_ID, | 63 syncable::GET_BY_ID, |
| 63 id); | 64 id); |
| 64 CHECK(meta_entry.good()); | 65 CHECK(meta_entry.good()); |
| 65 // This is the only change we make to the entry in this function. | 66 // This is the only change we make to the entry in this function. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 141 |
| 141 if (!meta_entry.Get(syncable::IS_DIR)) { | 142 if (!meta_entry.Get(syncable::IS_DIR)) { |
| 142 string bookmark_url = meta_entry.Get(syncable::BOOKMARK_URL); | 143 string bookmark_url = meta_entry.Get(syncable::BOOKMARK_URL); |
| 143 bookmark->set_bookmark_url(bookmark_url); | 144 bookmark->set_bookmark_url(bookmark_url); |
| 144 SyncerProtoUtil::CopyBlobIntoProtoBytes( | 145 SyncerProtoUtil::CopyBlobIntoProtoBytes( |
| 145 meta_entry.Get(syncable::BOOKMARK_FAVICON), | 146 meta_entry.Get(syncable::BOOKMARK_FAVICON), |
| 146 bookmark->mutable_bookmark_favicon()); | 147 bookmark->mutable_bookmark_favicon()); |
| 147 } | 148 } |
| 148 } | 149 } |
| 149 } | 150 } |
| 150 session->set_commit_message(message); | 151 session->status_controller()->mutable_commit_message()->CopyFrom(message); |
| 151 } | 152 } |
| 152 | 153 |
| 153 } // namespace browser_sync | 154 } // namespace browser_sync |
| OLD | NEW |