OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/process_commit_response_command.h" | 5 #include "chrome/browser/sync/engine/process_commit_response_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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 void IncrementErrorCounters(StatusController* status) { | 52 void IncrementErrorCounters(StatusController* status) { |
53 status->increment_num_consecutive_errors(); | 53 status->increment_num_consecutive_errors(); |
54 } | 54 } |
55 void ResetErrorCounters(StatusController* status) { | 55 void ResetErrorCounters(StatusController* status) { |
56 status->set_num_consecutive_errors(0); | 56 status->set_num_consecutive_errors(0); |
57 } | 57 } |
58 | 58 |
59 ProcessCommitResponseCommand::ProcessCommitResponseCommand() {} | 59 ProcessCommitResponseCommand::ProcessCommitResponseCommand() {} |
60 ProcessCommitResponseCommand::~ProcessCommitResponseCommand() {} | 60 ProcessCommitResponseCommand::~ProcessCommitResponseCommand() {} |
61 | 61 |
62 bool ProcessCommitResponseCommand::ModelNeutralExecuteImpl( | 62 void ProcessCommitResponseCommand::ExecuteImpl( |
| 63 sessions::SyncSession* session) { |
| 64 if (ModelNeutralShouldExitEarly(session)) |
| 65 return; |
| 66 |
| 67 ModelChangingSyncerCommand::ExecuteImpl(session); |
| 68 } |
| 69 |
| 70 bool ProcessCommitResponseCommand::ModelNeutralShouldExitEarly( |
63 sessions::SyncSession* session) { | 71 sessions::SyncSession* session) { |
64 ScopedDirLookup dir(session->context()->directory_manager(), | 72 ScopedDirLookup dir(session->context()->directory_manager(), |
65 session->context()->account_name()); | 73 session->context()->account_name()); |
66 if (!dir.good()) { | 74 if (!dir.good()) { |
67 LOG(ERROR) << "Scoped dir lookup failed!"; | 75 LOG(ERROR) << "Scoped dir lookup failed!"; |
68 return false; | 76 return true; |
69 } | 77 } |
70 | 78 |
71 StatusController* status = session->status_controller(); | 79 StatusController* status = session->status_controller(); |
72 const ClientToServerResponse& response(status->commit_response()); | 80 const ClientToServerResponse& response(status->commit_response()); |
73 const vector<syncable::Id>& commit_ids(status->commit_ids()); | 81 const vector<syncable::Id>& commit_ids(status->commit_ids()); |
74 | 82 |
75 if (!response.has_commit()) { | 83 if (!response.has_commit()) { |
76 // TODO(sync): What if we didn't try to commit anything? | 84 // TODO(sync): What if we didn't try to commit anything? |
77 LOG(WARNING) << "Commit response has no commit body!"; | 85 LOG(WARNING) << "Commit response has no commit body!"; |
78 IncrementErrorCounters(status); | 86 IncrementErrorCounters(status); |
79 return false; | 87 return true; |
80 } | 88 } |
81 | 89 |
82 const CommitResponse& cr = response.commit(); | 90 const CommitResponse& cr = response.commit(); |
83 int commit_count = commit_ids.size(); | 91 int commit_count = commit_ids.size(); |
84 if (cr.entryresponse_size() != commit_count) { | 92 if (cr.entryresponse_size() != commit_count) { |
85 LOG(ERROR) << "Commit response has wrong number of entries! Expected:" << | 93 LOG(ERROR) << "Commit response has wrong number of entries! Expected:" << |
86 commit_count << " Got:" << cr.entryresponse_size(); | 94 commit_count << " Got:" << cr.entryresponse_size(); |
87 for (int i = 0 ; i < cr.entryresponse_size() ; i++) { | 95 for (int i = 0 ; i < cr.entryresponse_size() ; i++) { |
88 LOG(ERROR) << "Response #" << i << " Value: " << | 96 LOG(ERROR) << "Response #" << i << " Value: " << |
89 cr.entryresponse(i).response_type(); | 97 cr.entryresponse(i).response_type(); |
90 if (cr.entryresponse(i).has_error_message()) | 98 if (cr.entryresponse(i).has_error_message()) |
91 LOG(ERROR) << " " << cr.entryresponse(i).error_message(); | 99 LOG(ERROR) << " " << cr.entryresponse(i).error_message(); |
92 } | 100 } |
93 IncrementErrorCounters(status); | 101 IncrementErrorCounters(status); |
94 return false; | 102 return true; |
95 } | 103 } |
96 return true; | 104 return false; |
97 } | 105 } |
98 | 106 |
99 void ProcessCommitResponseCommand::ModelChangingExecuteImpl( | 107 void ProcessCommitResponseCommand::ModelChangingExecuteImpl( |
100 SyncSession* session) { | 108 SyncSession* session) { |
101 ProcessCommitResponse(session); | 109 ProcessCommitResponse(session); |
102 ExtensionsActivityMonitor* monitor = session->context()->extensions_monitor(); | 110 ExtensionsActivityMonitor* monitor = session->context()->extensions_monitor(); |
103 if (session->status_controller()->HasBookmarkCommitActivity() && | 111 if (session->status_controller()->HasBookmarkCommitActivity() && |
104 session->status_controller()->syncer_status() | 112 session->status_controller()->syncer_status() |
105 .num_successful_bookmark_commits == 0) { | 113 .num_successful_bookmark_commits == 0) { |
106 monitor->PutRecords(session->extensions_activity()); | 114 monitor->PutRecords(session->extensions_activity()); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // been recursively deleted. | 493 // been recursively deleted. |
486 // TODO(nick): Here, commit_message.deleted() would be more correct than | 494 // TODO(nick): Here, commit_message.deleted() would be more correct than |
487 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then | 495 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then |
488 // deleted during the commit of the rename. Unit test & fix. | 496 // deleted during the commit of the rename. Unit test & fix. |
489 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { | 497 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { |
490 deleted_folders->insert(local_entry->Get(ID)); | 498 deleted_folders->insert(local_entry->Get(ID)); |
491 } | 499 } |
492 } | 500 } |
493 | 501 |
494 } // namespace browser_sync | 502 } // namespace browser_sync |
OLD | NEW |