Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: chrome/browser/sync/engine/process_updates_command.cc

Issue 386030: Relieve SyncerSession,SyncCycleState, SyncProcessState, SyncerSession, Syncer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "chrome/browser/sync/engine/syncer.h" 10 #include "chrome/browser/sync/engine/syncer.h"
11 #include "chrome/browser/sync/engine/syncer_proto_util.h" 11 #include "chrome/browser/sync/engine/syncer_proto_util.h"
12 #include "chrome/browser/sync/engine/syncer_session.h"
13 #include "chrome/browser/sync/engine/syncer_util.h" 12 #include "chrome/browser/sync/engine/syncer_util.h"
14 #include "chrome/browser/sync/engine/syncproto.h" 13 #include "chrome/browser/sync/engine/syncproto.h"
14 #include "chrome/browser/sync/sessions/sync_session.h"
15 #include "chrome/browser/sync/syncable/directory_manager.h" 15 #include "chrome/browser/sync/syncable/directory_manager.h"
16 #include "chrome/browser/sync/syncable/syncable.h" 16 #include "chrome/browser/sync/syncable/syncable.h"
17 17
18 using std::vector; 18 using std::vector;
19 19
20 namespace browser_sync { 20 namespace browser_sync {
21 21
22 using sessions::SyncSession;
23 using sessions::StatusController;
24
22 ProcessUpdatesCommand::ProcessUpdatesCommand() {} 25 ProcessUpdatesCommand::ProcessUpdatesCommand() {}
23 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} 26 ProcessUpdatesCommand::~ProcessUpdatesCommand() {}
24 27
25 void ProcessUpdatesCommand::ModelChangingExecuteImpl(SyncerSession* session) { 28 void ProcessUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) {
26 syncable::ScopedDirLookup dir(session->dirman(), session->account_name()); 29 syncable::ScopedDirLookup dir(session->context()->directory_manager(),
30 session->context()->account_name());
27 if (!dir.good()) { 31 if (!dir.good()) {
28 LOG(ERROR) << "Scoped dir lookup failed!"; 32 LOG(ERROR) << "Scoped dir lookup failed!";
29 return; 33 return;
30 } 34 }
31 SyncerStatus status(session);
32 35
33 const GetUpdatesResponse updates = session->update_response().get_updates(); 36 const GetUpdatesResponse& updates =
37 session->status_controller()->updates_response().get_updates();
34 const int update_count = updates.entries_size(); 38 const int update_count = updates.entries_size();
35 39
36 LOG(INFO) << "Get updates from ts " << dir->last_sync_timestamp() << 40 LOG(INFO) << "Get updates from ts " << dir->last_sync_timestamp() <<
37 " returned " << update_count << " updates."; 41 " returned " << update_count << " updates.";
38 42
43 StatusController* status = session->status_controller();
39 if (updates.has_changes_remaining()) { 44 if (updates.has_changes_remaining()) {
40 int64 changes_left = updates.changes_remaining(); 45 int64 changes_left = updates.changes_remaining();
41 LOG(INFO) << "Changes remaining:" << changes_left; 46 LOG(INFO) << "Changes remaining:" << changes_left;
42 status.set_num_server_changes_remaining(changes_left); 47 status->set_num_server_changes_remaining(changes_left);
43 } 48 }
44 49
45 int64 new_timestamp = 0; 50 int64 new_timestamp = 0;
46 if (updates.has_new_timestamp()) { 51 if (updates.has_new_timestamp()) {
47 new_timestamp = updates.new_timestamp(); 52 new_timestamp = updates.new_timestamp();
48 LOG(INFO) << "Get Updates got new timestamp: " << new_timestamp; 53 LOG(INFO) << "Get Updates got new timestamp: " << new_timestamp;
49 if (0 == update_count) { 54 if (0 == update_count) {
50 if (new_timestamp > dir->last_sync_timestamp()) { 55 if (new_timestamp > dir->last_sync_timestamp()) {
51 dir->set_last_sync_timestamp(new_timestamp); 56 dir->set_last_sync_timestamp(new_timestamp);
52 session->set_timestamp_dirty(); 57 status->set_timestamp_dirty(true);
53 } 58 }
54 return; 59 return;
55 } 60 }
56 } 61 }
57 62
58 // If we have updates that are ALL supposed to be skipped, we don't want to 63 // If we have updates that are ALL supposed to be skipped, we don't want to
59 // get them again. In fact, the account's final updates are all supposed to 64 // get them again. In fact, the account's final updates are all supposed to
60 // be skipped and we DON'T step past them, we will sync forever. 65 // be skipped and we DON'T step past them, we will sync forever.
61 int64 latest_skip_timestamp = 0; 66 int64 latest_skip_timestamp = 0;
62 bool any_non_skip_results = false; 67 bool any_non_skip_results = false;
63 vector<VerifiedUpdate>::iterator it; 68 const sessions::UpdateProgress& progress(status->update_progress());
64 for (it = session->VerifiedUpdatesBegin(); 69 vector<sessions::VerifiedUpdate>::const_iterator it;
65 it < session->VerifiedUpdatesEnd(); 70 for (it = progress.VerifiedUpdatesBegin();
71 it != progress.VerifiedUpdatesEnd();
66 ++it) { 72 ++it) {
67 const sync_pb::SyncEntity update = it->second; 73 const sync_pb::SyncEntity& update = it->second;
68 74
69 any_non_skip_results = (it->first != VERIFY_SKIP); 75 any_non_skip_results = (it->first != VERIFY_SKIP);
70 if (!any_non_skip_results) { 76 if (!any_non_skip_results) {
71 // ALL updates were to be skipped, including this one. 77 // ALL updates were to be skipped, including this one.
72 if (update.sync_timestamp() > latest_skip_timestamp) { 78 if (update.sync_timestamp() > latest_skip_timestamp) {
73 latest_skip_timestamp = update.sync_timestamp(); 79 latest_skip_timestamp = update.sync_timestamp();
74 } 80 }
75 } else { 81 } else {
76 latest_skip_timestamp = 0; 82 latest_skip_timestamp = 0;
77 } 83 }
(...skipping 13 matching lines...) Expand all
91 break; 97 break;
92 } 98 }
93 99
94 } 100 }
95 101
96 if (latest_skip_timestamp > new_timestamp) 102 if (latest_skip_timestamp > new_timestamp)
97 new_timestamp = latest_skip_timestamp; 103 new_timestamp = latest_skip_timestamp;
98 104
99 if (new_timestamp > dir->last_sync_timestamp()) { 105 if (new_timestamp > dir->last_sync_timestamp()) {
100 dir->set_last_sync_timestamp(new_timestamp); 106 dir->set_last_sync_timestamp(new_timestamp);
101 session->set_timestamp_dirty(); 107 status->set_timestamp_dirty(true);
102 } 108 }
103 109
104 status.zero_consecutive_problem_get_updates(); 110 status->set_num_consecutive_problem_get_updates(0);
105 status.zero_consecutive_errors(); 111 status->set_num_consecutive_errors(0);
106 status.set_current_sync_timestamp(dir->last_sync_timestamp()); 112 status->set_current_sync_timestamp(dir->last_sync_timestamp());
107 status.set_syncing(true); 113 status->set_syncing(true);
108 return; 114 return;
109 } 115 }
110 116
111 namespace { 117 namespace {
112 // Returns true if the entry is still ok to process. 118 // Returns true if the entry is still ok to process.
113 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry, 119 bool ReverifyEntry(syncable::WriteTransaction* trans, const SyncEntity& entry,
114 syncable::MutableEntry* same_id) { 120 syncable::MutableEntry* same_id) {
115 121
116 const bool deleted = entry.has_deleted() && entry.deleted(); 122 const bool deleted = entry.has_deleted() && entry.deleted();
117 const bool is_directory = entry.IsFolder(); 123 const bool is_directory = entry.IsFolder();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 !update_entry.Get(IS_UNSYNCED)) { 162 !update_entry.Get(IS_UNSYNCED)) {
157 // Previously this was a big issue but at this point we don't really care 163 // Previously this was a big issue but at this point we don't really care
158 // that much if things don't match up exactly. 164 // that much if things don't match up exactly.
159 LOG_IF(ERROR, !SyncerUtil::ServerAndLocalEntriesMatch(&update_entry)) 165 LOG_IF(ERROR, !SyncerUtil::ServerAndLocalEntriesMatch(&update_entry))
160 << update_entry; 166 << update_entry;
161 } 167 }
162 return SUCCESS_PROCESSED; 168 return SUCCESS_PROCESSED;
163 } 169 }
164 170
165 } // namespace browser_sync 171 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/process_updates_command.h ('k') | chrome/browser/sync/engine/resolve_conflicts_command.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698