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 <cstddef> |
7 #include <set> | 8 #include <set> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 14 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
14 #include "chrome/browser/sync/engine/syncer_util.h" | 15 #include "chrome/browser/sync/engine/syncer_util.h" |
15 #include "chrome/browser/sync/engine/syncproto.h" | 16 #include "chrome/browser/sync/engine/syncproto.h" |
16 #include "chrome/browser/sync/sessions/sync_session.h" | 17 #include "chrome/browser/sync/sessions/sync_session.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 void IncrementErrorCounters(StatusController* status) { | 53 void IncrementErrorCounters(StatusController* status) { |
53 status->increment_num_consecutive_errors(); | 54 status->increment_num_consecutive_errors(); |
54 } | 55 } |
55 void ResetErrorCounters(StatusController* status) { | 56 void ResetErrorCounters(StatusController* status) { |
56 status->set_num_consecutive_errors(0); | 57 status->set_num_consecutive_errors(0); |
57 } | 58 } |
58 | 59 |
59 ProcessCommitResponseCommand::ProcessCommitResponseCommand() {} | 60 ProcessCommitResponseCommand::ProcessCommitResponseCommand() {} |
60 ProcessCommitResponseCommand::~ProcessCommitResponseCommand() {} | 61 ProcessCommitResponseCommand::~ProcessCommitResponseCommand() {} |
61 | 62 |
| 63 bool ProcessCommitResponseCommand::HasCustomGroupsToChange() const { |
| 64 // TODO(akalin): Set to true. |
| 65 return false; |
| 66 } |
| 67 |
| 68 std::set<ModelSafeGroup> ProcessCommitResponseCommand::GetGroupsToChange( |
| 69 const sessions::SyncSession& session) const { |
| 70 std::set<ModelSafeGroup> groups_with_commits; |
| 71 syncable::ScopedDirLookup dir(session.context()->directory_manager(), |
| 72 session.context()->account_name()); |
| 73 if (!dir.good()) { |
| 74 LOG(ERROR) << "Scoped dir lookup failed!"; |
| 75 return groups_with_commits; |
| 76 } |
| 77 |
| 78 syncable::ReadTransaction trans(FROM_HERE, dir); |
| 79 const StatusController& status = session.status_controller(); |
| 80 for (size_t i = 0; i < status.commit_ids().size(); ++i) { |
| 81 groups_with_commits.insert( |
| 82 GetGroupForModelType(status.GetUnrestrictedCommitModelTypeAt(i), |
| 83 session.routing_info())); |
| 84 } |
| 85 |
| 86 return groups_with_commits; |
| 87 } |
| 88 |
62 bool ProcessCommitResponseCommand::ModelNeutralExecuteImpl( | 89 bool ProcessCommitResponseCommand::ModelNeutralExecuteImpl( |
63 sessions::SyncSession* session) { | 90 sessions::SyncSession* session) { |
64 ScopedDirLookup dir(session->context()->directory_manager(), | 91 ScopedDirLookup dir(session->context()->directory_manager(), |
65 session->context()->account_name()); | 92 session->context()->account_name()); |
66 if (!dir.good()) { | 93 if (!dir.good()) { |
67 LOG(ERROR) << "Scoped dir lookup failed!"; | 94 LOG(ERROR) << "Scoped dir lookup failed!"; |
68 return false; | 95 return false; |
69 } | 96 } |
70 | 97 |
71 const StatusController& status = session->status_controller(); | 98 const StatusController& status = session->status_controller(); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // been recursively deleted. | 512 // been recursively deleted. |
486 // TODO(nick): Here, commit_message.deleted() would be more correct than | 513 // 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 | 514 // 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. | 515 // deleted during the commit of the rename. Unit test & fix. |
489 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { | 516 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { |
490 deleted_folders->insert(local_entry->Get(ID)); | 517 deleted_folders->insert(local_entry->Get(ID)); |
491 } | 518 } |
492 } | 519 } |
493 | 520 |
494 } // namespace browser_sync | 521 } // namespace browser_sync |
OLD | NEW |