| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "components/sync/engine_impl/commit.h" | 5 #include "components/sync/engine_impl/commit.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/metrics/sparse_histogram.h" | 9 #include "base/metrics/sparse_histogram.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 CommitProcessor* commit_processor, | 41 CommitProcessor* commit_processor, |
| 42 ExtensionsActivity* extensions_activity) { | 42 ExtensionsActivity* extensions_activity) { |
| 43 // Gather per-type contributions. | 43 // Gather per-type contributions. |
| 44 ContributionMap contributions; | 44 ContributionMap contributions; |
| 45 commit_processor->GatherCommitContributions(requested_types, max_entries, | 45 commit_processor->GatherCommitContributions(requested_types, max_entries, |
| 46 cookie_jar_mismatch, | 46 cookie_jar_mismatch, |
| 47 cookie_jar_empty, &contributions); | 47 cookie_jar_empty, &contributions); |
| 48 | 48 |
| 49 // Give up if no one had anything to commit. | 49 // Give up if no one had anything to commit. |
| 50 if (contributions.empty()) | 50 if (contributions.empty()) |
| 51 return NULL; | 51 return nullptr; |
| 52 | 52 |
| 53 sync_pb::ClientToServerMessage message; | 53 sync_pb::ClientToServerMessage message; |
| 54 message.set_message_contents(sync_pb::ClientToServerMessage::COMMIT); | 54 message.set_message_contents(sync_pb::ClientToServerMessage::COMMIT); |
| 55 message.set_share(account_name); | 55 message.set_share(account_name); |
| 56 | 56 |
| 57 sync_pb::CommitMessage* commit_message = message.mutable_commit(); | 57 sync_pb::CommitMessage* commit_message = message.mutable_commit(); |
| 58 commit_message->set_cache_guid(cache_guid); | 58 commit_message->set_cache_guid(cache_guid); |
| 59 | 59 |
| 60 // Set extensions activity if bookmark commits are present. | 60 // Set extensions activity if bookmark commits are present. |
| 61 ExtensionsActivity::Records extensions_activity_buffer; | 61 ExtensionsActivity::Records extensions_activity_buffer; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 DVLOG(1) << "Sending commit message."; | 109 DVLOG(1) << "Sending commit message."; |
| 110 | 110 |
| 111 CommitRequestEvent request_event(base::Time::Now(), | 111 CommitRequestEvent request_event(base::Time::Now(), |
| 112 message_.commit().entries_size(), | 112 message_.commit().entries_size(), |
| 113 request_types, message_); | 113 request_types, message_); |
| 114 cycle->SendProtocolEvent(request_event); | 114 cycle->SendProtocolEvent(request_event); |
| 115 | 115 |
| 116 TRACE_EVENT_BEGIN0("sync", "PostCommit"); | 116 TRACE_EVENT_BEGIN0("sync", "PostCommit"); |
| 117 const SyncerError post_result = SyncerProtoUtil::PostClientToServerMessage( | 117 const SyncerError post_result = SyncerProtoUtil::PostClientToServerMessage( |
| 118 &message_, &response_, cycle, NULL); | 118 &message_, &response_, cycle, nullptr); |
| 119 TRACE_EVENT_END0("sync", "PostCommit"); | 119 TRACE_EVENT_END0("sync", "PostCommit"); |
| 120 | 120 |
| 121 // TODO(rlarocque): Use result that includes errors captured later? | 121 // TODO(rlarocque): Use result that includes errors captured later? |
| 122 CommitResponseEvent response_event(base::Time::Now(), post_result, response_); | 122 CommitResponseEvent response_event(base::Time::Now(), post_result, response_); |
| 123 cycle->SendProtocolEvent(response_event); | 123 cycle->SendProtocolEvent(response_event); |
| 124 | 124 |
| 125 if (post_result != SYNCER_OK) { | 125 if (post_result != SYNCER_OK) { |
| 126 LOG(WARNING) << "Post commit failed"; | 126 LOG(WARNING) << "Post commit failed"; |
| 127 return post_result; | 127 return post_result; |
| 128 } | 128 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 void Commit::CleanUp() { | 176 void Commit::CleanUp() { |
| 177 for (ContributionMap::const_iterator it = contributions_.begin(); | 177 for (ContributionMap::const_iterator it = contributions_.begin(); |
| 178 it != contributions_.end(); ++it) { | 178 it != contributions_.end(); ++it) { |
| 179 it->second->CleanUp(); | 179 it->second->CleanUp(); |
| 180 } | 180 } |
| 181 cleaned_up_ = true; | 181 cleaned_up_ = true; |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace syncer | 184 } // namespace syncer |
| OLD | NEW |