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

Unified Diff: chrome/browser/sync/sessions/sync_session.cc

Issue 8785015: Revert 112815 - [Sync] Make syncer commands avoid posting tasks on threads with no work to do (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/sessions/sync_session.h ('k') | chrome/browser/sync/sessions/sync_session_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/sessions/sync_session.cc
===================================================================
--- chrome/browser/sync/sessions/sync_session.cc (revision 112854)
+++ chrome/browser/sync/sessions/sync_session.cc (working copy)
@@ -6,48 +6,12 @@
#include <algorithm>
-#include "base/logging.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/model_type.h"
namespace browser_sync {
namespace sessions {
-namespace {
-
-std::set<ModelSafeGroup> ComputeEnabledGroups(
- const ModelSafeRoutingInfo& routing_info,
- const std::vector<ModelSafeWorker*>& workers) {
- std::set<ModelSafeGroup> enabled_groups;
- // Project the list of enabled types (i.e., types in the routing
- // info) to a list of enabled groups.
- for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin();
- it != routing_info.end(); ++it) {
- enabled_groups.insert(it->second);
- }
- // GROUP_PASSIVE is always enabled, since that's the group that
- // top-level folders map to.
- enabled_groups.insert(GROUP_PASSIVE);
- if (DCHECK_IS_ON()) {
- // We sometimes create dummy SyncSession objects (see
- // SyncScheduler::InitialSnapshot) so don't check in that case.
- if (!routing_info.empty() || !workers.empty()) {
- std::set<ModelSafeGroup> groups_with_workers;
- for (std::vector<ModelSafeWorker*>::const_iterator it = workers.begin();
- it != workers.end(); ++it) {
- groups_with_workers.insert((*it)->GetModelSafeGroup());
- }
- // All enabled groups should have a corresponding worker.
- DCHECK(std::includes(
- groups_with_workers.begin(), groups_with_workers.end(),
- enabled_groups.begin(), enabled_groups.end()));
- }
- }
- return enabled_groups;
-}
-
-} // namesepace
-
SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate,
const SyncSourceInfo& source,
const ModelSafeRoutingInfo& routing_info,
@@ -57,8 +21,7 @@
write_transaction_(NULL),
delegate_(delegate),
workers_(workers),
- routing_info_(routing_info),
- enabled_groups_(ComputeEnabledGroups(routing_info_, workers_)) {
+ routing_info_(routing_info) {
status_controller_.reset(new StatusController(routing_info_));
std::sort(workers_.begin(), workers_.end());
}
@@ -90,18 +53,15 @@
++it) {
routing_info_[it->first] = it->second;
}
-
- // Now update enabled groups.
- enabled_groups_ = ComputeEnabledGroups(routing_info_, workers_);
}
-void SyncSession::RebaseRoutingInfoWithLatest(const SyncSession& session) {
+void SyncSession::RebaseRoutingInfoWithLatest(SyncSession* session) {
ModelSafeRoutingInfo temp_routing_info;
// Take the intersecion and also set the routing info(it->second) from the
// passed in session.
for (ModelSafeRoutingInfo::const_iterator it =
- session.routing_info_.begin(); it != session.routing_info_.end();
+ session->routing_info_.begin(); it != session->routing_info_.end();
++it) {
if (routing_info_.find(it->first) != routing_info_.end()) {
temp_routing_info[it->first] = it->second;
@@ -112,17 +72,14 @@
routing_info_.swap(temp_routing_info);
// Now update the payload map.
- PurgeStalePayload(&source_.types, session.routing_info_);
+ PurgeStalePayload(&source_.types, session->routing_info_);
// Now update the workers.
std::vector<ModelSafeWorker*> temp;
std::set_intersection(workers_.begin(), workers_.end(),
- session.workers_.begin(), session.workers_.end(),
+ session->workers_.begin(), session->workers_.end(),
std::back_inserter(temp));
workers_.swap(temp);
-
- // Now update enabled groups.
- enabled_groups_ = ComputeEnabledGroups(routing_info_, workers_);
}
void SyncSession::ResetTransientState() {
@@ -184,46 +141,7 @@
status->conflicts_resolved();
// Or, we have conflicting updates, but we're making progress on
// resolving them...
-}
-
-const std::set<ModelSafeGroup>& SyncSession::GetEnabledGroups() const {
- return enabled_groups_;
-}
-
-std::set<ModelSafeGroup> SyncSession::GetEnabledGroupsWithConflicts() const {
- const std::set<ModelSafeGroup>& enabled_groups = GetEnabledGroups();
- std::set<ModelSafeGroup> enabled_groups_with_conflicts;
- for (std::set<ModelSafeGroup>::const_iterator it =
- enabled_groups.begin(); it != enabled_groups.end(); ++it) {
- const sessions::ConflictProgress* conflict_progress =
- status_controller_->GetUnrestrictedConflictProgress(*it);
- if (conflict_progress &&
- (conflict_progress->ConflictingItemsBegin() !=
- conflict_progress->ConflictingItemsEnd())) {
- enabled_groups_with_conflicts.insert(*it);
- }
}
- return enabled_groups_with_conflicts;
-}
-std::set<ModelSafeGroup>
- SyncSession::GetEnabledGroupsWithVerifiedUpdates() const {
- const std::set<ModelSafeGroup>& enabled_groups = GetEnabledGroups();
- std::set<ModelSafeGroup> enabled_groups_with_verified_updates;
- for (std::set<ModelSafeGroup>::const_iterator it =
- enabled_groups.begin(); it != enabled_groups.end(); ++it) {
- const UpdateProgress* update_progress =
- status_controller_->GetUnrestrictedUpdateProgress(*it);
- if (update_progress &&
- (update_progress->VerifiedUpdatesBegin() !=
- update_progress->VerifiedUpdatesEnd())) {
- enabled_groups_with_verified_updates.insert(*it);
- }
- }
-
- return enabled_groups_with_verified_updates;
-}
-
-
} // namespace sessions
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/sessions/sync_session.h ('k') | chrome/browser/sync/sessions/sync_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698