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

Unified Diff: chrome/browser/sync/engine/syncer_thread.cc

Issue 6270006: Revert 72685 - [SYNC] Refactor SyncSourceInfo and add support in chrome inval... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/engine/syncer_thread.h ('k') | chrome/browser/sync/engine/syncer_thread_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/syncer_thread.cc
===================================================================
--- chrome/browser/sync/engine/syncer_thread.cc (revision 72686)
+++ chrome/browser/sync/engine/syncer_thread.cc (working copy)
@@ -5,9 +5,8 @@
#include "chrome/browser/sync/engine/syncer_thread.h"
#include <algorithm>
+#include <map>
#include <queue>
-#include <string>
-#include <vector>
#include "base/rand_util.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
@@ -35,7 +34,6 @@
using sessions::SyncSession;
using sessions::SyncSessionSnapshot;
using sessions::SyncSourceInfo;
-using sessions::TypePayloadMap;
// We use high values here to ensure that failure to receive poll updates from
// the server doesn't result in rapid-fire polling from the client due to low
@@ -56,18 +54,6 @@
const int SyncerThread::kMaxBackoffSeconds = 60 * 60 * 4; // 4 hours.
-void SyncerThread::NudgeSyncerWithPayloads(
- int milliseconds_from_now,
- NudgeSource source,
- const TypePayloadMap& model_types_with_payloads) {
- base::AutoLock lock(lock_);
- if (vault_.syncer_ == NULL) {
- return;
- }
-
- NudgeSyncImpl(milliseconds_from_now, source, model_types_with_payloads);
-}
-
void SyncerThread::NudgeSyncerWithDataTypes(
int milliseconds_from_now,
NudgeSource source,
@@ -77,9 +63,7 @@
return;
}
- TypePayloadMap model_types_with_payloads =
- sessions::ModelTypeBitSetToTypePayloadMap(model_types, std::string());
- NudgeSyncImpl(milliseconds_from_now, source, model_types_with_payloads);
+ NudgeSyncImpl(milliseconds_from_now, source, model_types);
}
void SyncerThread::NudgeSyncer(
@@ -90,12 +74,8 @@
return;
}
- // Set all enabled datatypes.
- ModelSafeRoutingInfo routes;
- session_context_->registrar()->GetModelSafeRoutingInfo(&routes);
- TypePayloadMap model_types_with_payloads =
- sessions::RoutingInfoToTypePayloadMap(routes, std::string());
- NudgeSyncImpl(milliseconds_from_now, source, model_types_with_payloads);
+ syncable::ModelTypeBitSet model_types; // All false by default.
+ NudgeSyncImpl(milliseconds_from_now, source, model_types);
}
SyncerThread::SyncerThread(sessions::SyncSessionContext* context)
@@ -362,12 +342,11 @@
// Update timing information for how often these datatypes are triggering
// nudges.
base::TimeTicks now = TimeTicks::Now();
- if (!last_sync_time.is_null()) {
- TypePayloadMap::const_iterator iter;
- for (iter = session->source().types.begin();
- iter != session->source().types.end();
- ++iter) {
- syncable::PostTimeToTypeHistogram(iter->first,
+ for (size_t i = syncable::FIRST_REAL_MODEL_TYPE;
+ i < session->source().second.size();
+ ++i) {
+ if (session->source().second[i]) {
+ syncable::PostTimeToTypeHistogram(syncable::ModelType(i),
now - last_sync_time);
}
}
@@ -595,7 +574,7 @@
bool* was_nudged) {
bool nudged = false;
NudgeSource nudge_source = kUnknown;
- TypePayloadMap model_types_with_payloads;
+ syncable::ModelTypeBitSet model_types;
// Has the previous sync cycle completed?
if (continue_sync_cycle)
nudge_source = kContinuation;
@@ -604,13 +583,13 @@
if (!vault_.pending_nudge_time_.is_null()) {
if (!was_throttled) {
nudge_source = vault_.pending_nudge_source_;
- model_types_with_payloads = vault_.pending_nudge_types_;
+ model_types = vault_.pending_nudge_types_;
nudged = true;
}
VLOG(1) << "Clearing pending nudge from " << vault_.pending_nudge_source_
<< " at tick " << vault_.pending_nudge_time_.ToInternalValue();
vault_.pending_nudge_source_ = kUnknown;
- vault_.pending_nudge_types_.clear();
+ vault_.pending_nudge_types_.reset();
vault_.pending_nudge_time_ = base::TimeTicks();
}
@@ -620,12 +599,11 @@
// from syncer having more work to do. This will be handled properly with
// the message loop based syncer thread, bug 26339.
return MakeSyncSourceInfo(nudged || nudge_source == kContinuation,
- nudge_source, model_types_with_payloads, initial_sync);
+ nudge_source, model_types, initial_sync);
}
SyncSourceInfo SyncerThread::MakeSyncSourceInfo(bool nudged,
- NudgeSource nudge_source,
- const TypePayloadMap& model_types_with_payloads,
+ NudgeSource nudge_source, const syncable::ModelTypeBitSet& nudge_types,
bool* initial_sync) {
sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source =
sync_pb::GetUpdatesCallerInfo::UNKNOWN;
@@ -654,19 +632,7 @@
break;
}
}
-
- TypePayloadMap sync_source_types;
- if (model_types_with_payloads.empty()) {
- // No datatypes requested. This must be a poll so set all enabled datatypes.
- ModelSafeRoutingInfo routes;
- session_context_->registrar()->GetModelSafeRoutingInfo(&routes);
- sync_source_types = sessions::RoutingInfoToTypePayloadMap(routes,
- std::string());
- } else {
- sync_source_types = model_types_with_payloads;
- }
-
- return SyncSourceInfo(updates_source, sync_source_types);
+ return SyncSourceInfo(updates_source, nudge_types);
}
void SyncerThread::CreateSyncer(const std::string& dirname) {
@@ -768,10 +734,9 @@
}
// Called with mutex_ already locked.
-void SyncerThread::NudgeSyncImpl(
- int milliseconds_from_now,
- NudgeSource source,
- const TypePayloadMap& model_types_with_payloads) {
+void SyncerThread::NudgeSyncImpl(int milliseconds_from_now,
+ NudgeSource source,
+ const syncable::ModelTypeBitSet& model_types) {
// TODO(sync): Add the option to reset the backoff state machine.
// This is needed so nudges that are a result of the user's desire
// to download updates for a new data type can be satisfied quickly.
@@ -782,12 +747,11 @@
return;
}
- // Union the current TypePayloadMap with any from nudges that may have already
+ // Union the current bitset with any from nudges that may have already
// posted (coalesce the nudge datatype information).
// TODO(tim): It seems weird to do this if the sources don't match up (e.g.
// if pending_source is kLocal and |source| is kClearPrivateData).
- sessions::CoalescePayloads(&vault_.pending_nudge_types_,
- model_types_with_payloads);
+ vault_.pending_nudge_types_ |= model_types;
const TimeTicks nudge_time = TimeTicks::Now() +
TimeDelta::FromMilliseconds(milliseconds_from_now);
« no previous file with comments | « chrome/browser/sync/engine/syncer_thread.h ('k') | chrome/browser/sync/engine/syncer_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698