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

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

Issue 6104003: sync: use progress markers instead of timestamps during GetUpdates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tim's fixes Created 9 years, 11 months 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
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/engine/syncer_end_command.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/syncapi.h" 5 #include "chrome/browser/sync/engine/syncapi.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <iomanip> 8 #include <iomanip>
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 TalkMediator* talk_mediator() { return talk_mediator_.get(); } 1056 TalkMediator* talk_mediator() { return talk_mediator_.get(); }
1057 void set_observer(SyncManager::Observer* observer) { observer_ = observer; } 1057 void set_observer(SyncManager::Observer* observer) { observer_ = observer; }
1058 UserShare* GetUserShare() { return &share_; } 1058 UserShare* GetUserShare() { return &share_; }
1059 1059
1060 // Return the currently active (validated) username for use with syncable 1060 // Return the currently active (validated) username for use with syncable
1061 // types. 1061 // types.
1062 const std::string& username_for_share() const { 1062 const std::string& username_for_share() const {
1063 return share_.name; 1063 return share_.name;
1064 } 1064 }
1065 1065
1066 // Note about SyncManager::Status implementation: Status is a trimmed 1066 Status GetStatus();
1067 // down AllStatus::Status, augmented with authentication failure information
1068 // gathered from the internal AuthWatcher. The sync UI itself hooks up to
1069 // various sources like the AuthWatcher individually, but with syncapi we try
1070 // to keep everything status-related in one place. This means we have to
1071 // privately manage state about authentication failures, and whenever the
1072 // status or status summary is requested we aggregate this state with
1073 // AllStatus::Status information.
1074 Status ComputeAggregatedStatus();
1075 Status::Summary ComputeAggregatedStatusSummary();
1076 1067
1077 // See SyncManager::Shutdown for information. 1068 // See SyncManager::Shutdown for information.
1078 void Shutdown(); 1069 void Shutdown();
1079 1070
1080 // Whether we're initialized to the point of being able to accept changes 1071 // Whether we're initialized to the point of being able to accept changes
1081 // (and hence allow transaction creation). See initialized_ for details. 1072 // (and hence allow transaction creation). See initialized_ for details.
1082 bool initialized() const { 1073 bool initialized() const {
1083 AutoLock lock(initialized_mutex_); 1074 AutoLock lock(initialized_mutex_);
1084 return initialized_; 1075 return initialized_;
1085 } 1076 }
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 change_buffers_[type].PushDeletedItem(id); 2048 change_buffers_[type].PushDeletedItem(id);
2058 else if (exists_now && existed_before && VisiblePropertiesDiffer(*i, e)) 2049 else if (exists_now && existed_before && VisiblePropertiesDiffer(*i, e))
2059 change_buffers_[type].PushUpdatedItem(id, VisiblePositionsDiffer(*i, e)); 2050 change_buffers_[type].PushUpdatedItem(id, VisiblePositionsDiffer(*i, e));
2060 2051
2061 SetExtraChangeRecordData(id, type, &change_buffers_[type], 2052 SetExtraChangeRecordData(id, type, &change_buffers_[type],
2062 dir_manager()->cryptographer(), *i, 2053 dir_manager()->cryptographer(), *i,
2063 existed_before, exists_now); 2054 existed_before, exists_now);
2064 } 2055 }
2065 } 2056 }
2066 2057
2067 SyncManager::Status::Summary 2058 SyncManager::Status SyncManager::SyncInternal::GetStatus() {
2068 SyncManager::SyncInternal::ComputeAggregatedStatusSummary() { 2059 return allstatus_.status();
2069 switch (allstatus_.status().icon) {
2070 case AllStatus::OFFLINE:
2071 return Status::OFFLINE;
2072 case AllStatus::OFFLINE_UNSYNCED:
2073 return Status::OFFLINE_UNSYNCED;
2074 case AllStatus::SYNCING:
2075 return Status::SYNCING;
2076 case AllStatus::READY:
2077 return Status::READY;
2078 case AllStatus::CONFLICT:
2079 return Status::CONFLICT;
2080 case AllStatus::OFFLINE_UNUSABLE:
2081 return Status::OFFLINE_UNUSABLE;
2082 default:
2083 return Status::INVALID;
2084 }
2085 }
2086
2087 SyncManager::Status SyncManager::SyncInternal::ComputeAggregatedStatus() {
2088 Status return_status =
2089 { ComputeAggregatedStatusSummary(),
2090 allstatus_.status().authenticated,
2091 allstatus_.status().server_up,
2092 allstatus_.status().server_reachable,
2093 allstatus_.status().server_broken,
2094 allstatus_.status().notifications_enabled,
2095 allstatus_.status().notifications_received,
2096 allstatus_.status().notifications_sent,
2097 allstatus_.status().unsynced_count,
2098 allstatus_.status().conflicting_count,
2099 allstatus_.status().syncing,
2100 allstatus_.status().initial_sync_ended,
2101 allstatus_.status().syncer_stuck,
2102 allstatus_.status().updates_available,
2103 allstatus_.status().updates_received,
2104 allstatus_.status().disk_full,
2105 false, // TODO(ncarter): invalid store?
2106 allstatus_.status().max_consecutive_errors};
2107 return return_status;
2108 } 2060 }
2109 2061
2110 void SyncManager::SyncInternal::OnSyncEngineEvent( 2062 void SyncManager::SyncInternal::OnSyncEngineEvent(
2111 const SyncEngineEvent& event) { 2063 const SyncEngineEvent& event) {
2112 if (!observer_) 2064 if (!observer_)
2113 return; 2065 return;
2114 2066
2115 // Only send an event if this is due to a cycle ending and this cycle 2067 // Only send an event if this is due to a cycle ending and this cycle
2116 // concludes a canonical "sync" process; that is, based on what is known 2068 // concludes a canonical "sync" process; that is, based on what is known
2117 // locally we are "all happy" and up-to-date. There may be new changes on 2069 // locally we are "all happy" and up-to-date. There may be new changes on
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 if (VLOG_IS_ON(1)) { 2255 if (VLOG_IS_ON(1)) {
2304 std::string encoded_state; 2256 std::string encoded_state;
2305 base::Base64Encode(state, &encoded_state); 2257 base::Base64Encode(state, &encoded_state);
2306 VLOG(1) << "Writing notification state: " << encoded_state; 2258 VLOG(1) << "Writing notification state: " << encoded_state;
2307 } 2259 }
2308 lookup->SetNotificationState(state); 2260 lookup->SetNotificationState(state);
2309 lookup->SaveChanges(); 2261 lookup->SaveChanges();
2310 } 2262 }
2311 2263
2312 SyncManager::Status::Summary SyncManager::GetStatusSummary() const { 2264 SyncManager::Status::Summary SyncManager::GetStatusSummary() const {
2313 return data_->ComputeAggregatedStatusSummary(); 2265 return data_->GetStatus().summary;
2314 } 2266 }
2315 2267
2316 SyncManager::Status SyncManager::GetDetailedStatus() const { 2268 SyncManager::Status SyncManager::GetDetailedStatus() const {
2317 return data_->ComputeAggregatedStatus(); 2269 return data_->GetStatus();
2318 } 2270 }
2319 2271
2320 SyncManager::SyncInternal* SyncManager::GetImpl() const { return data_; } 2272 SyncManager::SyncInternal* SyncManager::GetImpl() const { return data_; }
2321 2273
2322 void SyncManager::SaveChanges() { 2274 void SyncManager::SaveChanges() {
2323 data_->SaveChanges(); 2275 data_->SaveChanges();
2324 } 2276 }
2325 2277
2326 void SyncManager::SyncInternal::SaveChanges() { 2278 void SyncManager::SyncInternal::SaveChanges() {
2327 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); 2279 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
(...skipping 23 matching lines...) Expand all
2351 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; 2303 DCHECK(data_->initialized()) << "GetUserShare requires initialization!";
2352 return data_->GetUserShare(); 2304 return data_->GetUserShare();
2353 } 2305 }
2354 2306
2355 bool SyncManager::HasUnsyncedItems() const { 2307 bool SyncManager::HasUnsyncedItems() const {
2356 sync_api::ReadTransaction trans(GetUserShare()); 2308 sync_api::ReadTransaction trans(GetUserShare());
2357 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); 2309 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0);
2358 } 2310 }
2359 2311
2360 } // namespace sync_api 2312 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/engine/syncer_end_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698