OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "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" |
11 #include "chrome/browser/sync/engine/syncer.h" | 11 #include "chrome/browser/sync/engine/syncer.h" |
(...skipping 14 matching lines...) Expand all Loading... |
26 using sessions::UpdateProgress; | 26 using sessions::UpdateProgress; |
27 | 27 |
28 ProcessUpdatesCommand::ProcessUpdatesCommand() {} | 28 ProcessUpdatesCommand::ProcessUpdatesCommand() {} |
29 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} | 29 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} |
30 | 30 |
31 std::set<ModelSafeGroup> ProcessUpdatesCommand::GetGroupsToChange( | 31 std::set<ModelSafeGroup> ProcessUpdatesCommand::GetGroupsToChange( |
32 const sessions::SyncSession& session) const { | 32 const sessions::SyncSession& session) const { |
33 return session.GetEnabledGroupsWithVerifiedUpdates(); | 33 return session.GetEnabledGroupsWithVerifiedUpdates(); |
34 } | 34 } |
35 | 35 |
36 void ProcessUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { | 36 SyncerError ProcessUpdatesCommand::ModelChangingExecuteImpl( |
| 37 SyncSession* session) { |
37 syncable::ScopedDirLookup dir(session->context()->directory_manager(), | 38 syncable::ScopedDirLookup dir(session->context()->directory_manager(), |
38 session->context()->account_name()); | 39 session->context()->account_name()); |
39 if (!dir.good()) { | 40 if (!dir.good()) { |
40 LOG(ERROR) << "Scoped dir lookup failed!"; | 41 LOG(ERROR) << "Scoped dir lookup failed!"; |
41 return; | 42 return DIRECTORY_LOOKUP_FAILED; |
42 } | 43 } |
43 | 44 |
44 const sessions::UpdateProgress* progress = | 45 const sessions::UpdateProgress* progress = |
45 session->status_controller().update_progress(); | 46 session->status_controller().update_progress(); |
46 if (!progress) | 47 if (!progress) |
47 return; // Nothing to do. | 48 return SYNCER_OK; // Nothing to do. |
48 | 49 |
49 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); | 50 syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); |
50 vector<sessions::VerifiedUpdate>::const_iterator it; | 51 vector<sessions::VerifiedUpdate>::const_iterator it; |
51 for (it = progress->VerifiedUpdatesBegin(); | 52 for (it = progress->VerifiedUpdatesBegin(); |
52 it != progress->VerifiedUpdatesEnd(); | 53 it != progress->VerifiedUpdatesEnd(); |
53 ++it) { | 54 ++it) { |
54 const sync_pb::SyncEntity& update = it->second; | 55 const sync_pb::SyncEntity& update = it->second; |
55 | 56 |
56 if (it->first != VERIFY_SUCCESS && it->first != VERIFY_UNDELETE) | 57 if (it->first != VERIFY_SUCCESS && it->first != VERIFY_UNDELETE) |
57 continue; | 58 continue; |
58 switch (ProcessUpdate(dir, update, | 59 switch (ProcessUpdate(dir, update, |
59 session->context()->directory_manager()->GetCryptographer(&trans), | 60 session->context()->directory_manager()->GetCryptographer(&trans), |
60 &trans)) { | 61 &trans)) { |
61 case SUCCESS_PROCESSED: | 62 case SUCCESS_PROCESSED: |
62 case SUCCESS_STORED: | 63 case SUCCESS_STORED: |
63 break; | 64 break; |
64 default: | 65 default: |
65 NOTREACHED(); | 66 NOTREACHED(); |
66 break; | 67 break; |
67 } | 68 } |
68 } | 69 } |
69 | 70 |
70 StatusController* status = session->mutable_status_controller(); | 71 StatusController* status = session->mutable_status_controller(); |
71 status->set_num_consecutive_errors(0); | 72 status->set_num_consecutive_errors(0); |
72 status->mutable_update_progress()->ClearVerifiedUpdates(); | 73 status->mutable_update_progress()->ClearVerifiedUpdates(); |
| 74 return SYNCER_OK; |
73 } | 75 } |
74 | 76 |
75 namespace { | 77 namespace { |
76 // Returns true if the entry is still ok to process. | 78 // Returns true if the entry is still ok to process. |
77 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry, | 79 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry, |
78 syncable::MutableEntry* same_id) { | 80 syncable::MutableEntry* same_id) { |
79 | 81 |
80 const bool deleted = entry.has_deleted() && entry.deleted(); | 82 const bool deleted = entry.has_deleted() && entry.deleted(); |
81 const bool is_directory = entry.IsFolder(); | 83 const bool is_directory = entry.IsFolder(); |
82 const syncable::ModelType model_type = entry.GetModelType(); | 84 const syncable::ModelType model_type = entry.GetModelType(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, | 182 target_entry.Put(syncable::BASE_SERVER_SPECIFICS, |
181 sync_pb::EntitySpecifics()); | 183 sync_pb::EntitySpecifics()); |
182 } | 184 } |
183 | 185 |
184 SyncerUtil::UpdateServerFieldsFromUpdate(&target_entry, update, name); | 186 SyncerUtil::UpdateServerFieldsFromUpdate(&target_entry, update, name); |
185 | 187 |
186 return SUCCESS_PROCESSED; | 188 return SUCCESS_PROCESSED; |
187 } | 189 } |
188 | 190 |
189 } // namespace browser_sync | 191 } // namespace browser_sync |
OLD | NEW |