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_updates_command.h" | 5 #include "chrome/browser/sync/engine/process_updates_command.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 using sessions::UpdateProgress; | 25 using sessions::UpdateProgress; |
26 | 26 |
27 ProcessUpdatesCommand::ProcessUpdatesCommand() {} | 27 ProcessUpdatesCommand::ProcessUpdatesCommand() {} |
28 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} | 28 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} |
29 | 29 |
30 std::set<ModelSafeGroup> ProcessUpdatesCommand::GetGroupsToChange( | 30 std::set<ModelSafeGroup> ProcessUpdatesCommand::GetGroupsToChange( |
31 const sessions::SyncSession& session) const { | 31 const sessions::SyncSession& session) const { |
32 return session.GetEnabledGroupsWithVerifiedUpdates(); | 32 return session.GetEnabledGroupsWithVerifiedUpdates(); |
33 } | 33 } |
34 | 34 |
35 void ProcessUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { | 35 SyncerError ProcessUpdatesCommand::ModelChangingExecuteImpl( |
| 36 SyncSession* session) { |
36 syncable::ScopedDirLookup dir(session->context()->directory_manager(), | 37 syncable::ScopedDirLookup dir(session->context()->directory_manager(), |
37 session->context()->account_name()); | 38 session->context()->account_name()); |
38 if (!dir.good()) { | 39 if (!dir.good()) { |
39 LOG(ERROR) << "Scoped dir lookup failed!"; | 40 LOG(ERROR) << "Scoped dir lookup failed!"; |
40 return; | 41 return DIRECTORY_LOOKUP_FAILED; |
41 } | 42 } |
42 | 43 |
43 const sessions::UpdateProgress* progress = | 44 const sessions::UpdateProgress* progress = |
44 session->status_controller().update_progress(); | 45 session->status_controller().update_progress(); |
45 if (!progress) | 46 if (!progress) |
46 return; // Nothing to do. | 47 return NO_ERROR; // Nothing to do. |
47 | 48 |
48 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); | 49 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); |
49 vector<sessions::VerifiedUpdate>::const_iterator it; | 50 vector<sessions::VerifiedUpdate>::const_iterator it; |
50 for (it = progress->VerifiedUpdatesBegin(); | 51 for (it = progress->VerifiedUpdatesBegin(); |
51 it != progress->VerifiedUpdatesEnd(); | 52 it != progress->VerifiedUpdatesEnd(); |
52 ++it) { | 53 ++it) { |
53 const sync_pb::SyncEntity& update = it->second; | 54 const sync_pb::SyncEntity& update = it->second; |
54 | 55 |
55 if (it->first != VERIFY_SUCCESS && it->first != VERIFY_UNDELETE) | 56 if (it->first != VERIFY_SUCCESS && it->first != VERIFY_UNDELETE) |
56 continue; | 57 continue; |
57 switch (ProcessUpdate(dir, update, &trans)) { | 58 switch (ProcessUpdate(dir, update, &trans)) { |
58 case SUCCESS_PROCESSED: | 59 case SUCCESS_PROCESSED: |
59 case SUCCESS_STORED: | 60 case SUCCESS_STORED: |
60 break; | 61 break; |
61 default: | 62 default: |
62 NOTREACHED(); | 63 NOTREACHED(); |
63 break; | 64 break; |
64 } | 65 } |
65 } | 66 } |
66 | 67 |
67 StatusController* status = session->mutable_status_controller(); | 68 StatusController* status = session->mutable_status_controller(); |
68 status->set_num_consecutive_errors(0); | 69 status->set_num_consecutive_errors(0); |
69 status->mutable_update_progress()->ClearVerifiedUpdates(); | 70 status->mutable_update_progress()->ClearVerifiedUpdates(); |
| 71 return NO_ERROR; |
70 } | 72 } |
71 | 73 |
72 namespace { | 74 namespace { |
73 // Returns true if the entry is still ok to process. | 75 // Returns true if the entry is still ok to process. |
74 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry, | 76 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry, |
75 syncable::MutableEntry* same_id) { | 77 syncable::MutableEntry* same_id) { |
76 | 78 |
77 const bool deleted = entry.has_deleted() && entry.deleted(); | 79 const bool deleted = entry.has_deleted() && entry.deleted(); |
78 const bool is_directory = entry.IsFolder(); | 80 const bool is_directory = entry.IsFolder(); |
79 const syncable::ModelType model_type = entry.GetModelType(); | 81 const syncable::ModelType model_type = entry.GetModelType(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Force application of this update, no matter what. | 145 // Force application of this update, no matter what. |
144 target_entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); | 146 target_entry.Put(syncable::IS_UNAPPLIED_UPDATE, true); |
145 } | 147 } |
146 | 148 |
147 SyncerUtil::UpdateServerFieldsFromUpdate(&target_entry, update, name); | 149 SyncerUtil::UpdateServerFieldsFromUpdate(&target_entry, update, name); |
148 | 150 |
149 return SUCCESS_PROCESSED; | 151 return SUCCESS_PROCESSED; |
150 } | 152 } |
151 | 153 |
152 } // namespace browser_sync | 154 } // namespace browser_sync |
OLD | NEW |