summaryrefslogtreecommitdiffstats
path: root/sync
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 23:58:41 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 23:58:41 +0000
commit16449b24f3f63906f32f6a89032617c73ff72edf (patch)
treecde2539a385947dd3bf11ba686316a3e946f025a /sync
parent9835d34c8ece44b0dabcf650310a1bb8b7d017c6 (diff)
downloadchromium_src-16449b24f3f63906f32f6a89032617c73ff72edf.zip
chromium_src-16449b24f3f63906f32f6a89032617c73ff72edf.tar.gz
chromium_src-16449b24f3f63906f32f6a89032617c73ff72edf.tar.bz2
sync: Remove UpdateProgress and related code
Following the merge of the process updates and verify updates step, there is no longer any need for the UpdateProgress class. Its only use outside of tests was to pass data between the verify and update steps during a sync cycle. The class had some use in tests, but most of the assertions based on it were somewhat redundant. They can be replaced by assertions on similar, but non-ModelSafe, counts. BUG=156238 Review URL: https://chromiumcodereview.appspot.com/11190013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r--sync/engine/apply_updates_command.cc3
-rw-r--r--sync/engine/apply_updates_command_unittest.cc158
-rw-r--r--sync/engine/process_updates_command.cc3
-rw-r--r--sync/engine/update_applicator.cc69
-rw-r--r--sync/engine/update_applicator.h35
-rw-r--r--sync/sessions/session_state.cc57
-rw-r--r--sync/sessions/session_state.h52
-rw-r--r--sync/sessions/status_controller.cc37
-rw-r--r--sync/sessions/status_controller.h9
-rw-r--r--sync/sessions/status_controller_unittest.cc28
10 files changed, 70 insertions, 381 deletions
diff --git a/sync/engine/apply_updates_command.cc b/sync/engine/apply_updates_command.cc
index e43f071..bff83f2 100644
--- a/sync/engine/apply_updates_command.cc
+++ b/sync/engine/apply_updates_command.cc
@@ -71,9 +71,6 @@ SyncerError ApplyUpdatesCommand::ModelChangingExecuteImpl(
session->status_controller().group_restriction());
applicator.AttemptApplications(&trans, handles,
session->mutable_status_controller());
- applicator.SaveProgressIntoSessionState(
- session->mutable_status_controller()->mutable_simple_conflict_ids(),
- session->mutable_status_controller()->mutable_update_progress());
// This might be the first time we've fully completed a sync cycle, for
// some subset of the currently synced datatypes.
diff --git a/sync/engine/apply_updates_command_unittest.cc b/sync/engine/apply_updates_command_unittest.cc
index 01ddd93..b261c1d 100644
--- a/sync/engine/apply_updates_command_unittest.cc
+++ b/sync/engine/apply_updates_command_unittest.cc
@@ -81,19 +81,14 @@ TEST_F(ApplyUpdatesCommandTest, Simple) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
-
- EXPECT_EQ(0, status->num_simple_conflicts())
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_EQ(0, status.num_simple_conflicts())
<< "Simple update shouldn't result in conflicts";
- EXPECT_EQ(0, status->num_encryption_conflicts())
+ EXPECT_EQ(0, status.num_encryption_conflicts())
<< "Simple update shouldn't result in conflicts";
- EXPECT_EQ(0, status->num_hierarchy_conflicts())
+ EXPECT_EQ(0, status.num_hierarchy_conflicts())
<< "Simple update shouldn't result in conflicts";
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI);
- ASSERT_TRUE(status->update_progress());
- EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize())
- << "All updates should have been attempted";
- EXPECT_EQ(2, status->update_progress()->SuccessfullyAppliedUpdateCount())
+ EXPECT_EQ(2, status.num_updates_applied())
<< "All items should have been successfully applied";
}
@@ -115,14 +110,10 @@ TEST_F(ApplyUpdatesCommandTest, UpdateWithChildrenBeforeParents) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
- EXPECT_EQ(0, status->num_simple_conflicts())
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_EQ(0, status.num_simple_conflicts())
<< "Simple update shouldn't result in conflicts, even if out-of-order";
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI);
- ASSERT_TRUE(status->update_progress());
- EXPECT_EQ(5, status->update_progress()->AppliedUpdatesSize())
- << "All updates should have been attempted";
- EXPECT_EQ(5, status->update_progress()->SuccessfullyAppliedUpdateCount())
+ EXPECT_EQ(5, status.num_updates_applied())
<< "All updates should have been successfully applied";
}
@@ -136,8 +127,8 @@ TEST_F(ApplyUpdatesCommandTest, SimpleConflict) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
- EXPECT_EQ(1, status->num_simple_conflicts())
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_EQ(1, status.num_simple_conflicts())
<< "Unsynced and unapplied item should be a simple conflict";
}
@@ -164,15 +155,12 @@ TEST_F(ApplyUpdatesCommandTest, HierarchyAndSimpleConflict) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
+ const sessions::StatusController& status = session()->status_controller();
// An update that is both a simple conflict and a hierarchy conflict should be
// treated as a hierarchy conflict.
- EXPECT_EQ(1, status->num_hierarchy_conflicts());
- EXPECT_EQ(0, status->num_simple_conflicts());
-
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI);
- EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize());
+ EXPECT_EQ(1, status.num_hierarchy_conflicts());
+ EXPECT_EQ(0, status.num_simple_conflicts());
}
@@ -210,14 +198,11 @@ TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDirectoryLoop) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
+ const sessions::StatusController& status = session()->status_controller();
// This should count as a hierarchy conflict.
- EXPECT_EQ(1, status->num_hierarchy_conflicts());
- EXPECT_EQ(0, status->num_simple_conflicts());
-
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI);
- EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize());
+ EXPECT_EQ(1, status.num_hierarchy_conflicts());
+ EXPECT_EQ(0, status.num_simple_conflicts());
}
// Runs the ApplyUpdatesCommand on a directory where the server sent us an
@@ -247,9 +232,9 @@ TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDeletedParent) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
- EXPECT_EQ(1, status->num_hierarchy_conflicts());
- EXPECT_EQ(0, status->num_simple_conflicts());
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_EQ(1, status.num_hierarchy_conflicts());
+ EXPECT_EQ(0, status.num_simple_conflicts());
}
// Runs the ApplyUpdatesCommand on a directory where the server is trying to
@@ -285,10 +270,10 @@ TEST_F(ApplyUpdatesCommandTest, HierarchyConflictDeleteNonEmptyDirectory) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
+ const sessions::StatusController& status = session()->status_controller();
// This should count as a hierarchy conflict.
- EXPECT_EQ(1, status->num_hierarchy_conflicts());
- EXPECT_EQ(0, status->num_simple_conflicts());
+ EXPECT_EQ(1, status.num_hierarchy_conflicts());
+ EXPECT_EQ(0, status.num_simple_conflicts());
}
// Runs the ApplyUpdatesCommand on a server-created item that has a locally
@@ -304,19 +289,13 @@ TEST_F(ApplyUpdatesCommandTest, HierarchyConflictUnknownParent) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
-
- EXPECT_EQ(0, status->num_simple_conflicts())
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_EQ(0, status.num_simple_conflicts())
<< "Updates with unknown parent should not be treated as 'simple'"
<< " conflicts";
- EXPECT_EQ(2, status->num_hierarchy_conflicts())
+ EXPECT_EQ(2, status.num_hierarchy_conflicts())
<< "All updates with an unknown ancestors should be in conflict";
-
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI);
- ASSERT_TRUE(status->update_progress());
- EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize())
- << "All updates should have been attempted";
- EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount())
+ EXPECT_EQ(0, status.num_updates_applied())
<< "No item with an unknown ancestor should be applied";
}
@@ -339,16 +318,10 @@ TEST_F(ApplyUpdatesCommandTest, ItemsBothKnownAndUnknown) {
ExpectGroupToChange(apply_updates_command_, GROUP_UI);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
-
- EXPECT_EQ(2, status->num_hierarchy_conflicts())
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_EQ(2, status.num_hierarchy_conflicts())
<< "The updates with unknown ancestors should be in conflict";
-
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI);
- ASSERT_TRUE(status->update_progress());
- EXPECT_EQ(6, status->update_progress()->AppliedUpdatesSize())
- << "All updates should have been attempted";
- EXPECT_EQ(4, status->update_progress()->SuccessfullyAppliedUpdateCount())
+ EXPECT_EQ(4, status.num_updates_applied())
<< "The updates with known ancestors should be successfully applied";
}
@@ -376,16 +349,10 @@ TEST_F(ApplyUpdatesCommandTest, DecryptablePassword) {
ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
-
- EXPECT_EQ(0, status->num_simple_conflicts())
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_EQ(0, status.num_simple_conflicts())
<< "No update should be in conflict because they're all decryptable";
-
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD);
- ASSERT_TRUE(status->update_progress());
- EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize())
- << "All updates should have been attempted";
- EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount())
+ EXPECT_EQ(1, status.num_updates_applied())
<< "The updates that can be decrypted should be applied";
}
@@ -405,30 +372,16 @@ TEST_F(ApplyUpdatesCommandTest, UndecryptableData) {
ExpectGroupsToChange(apply_updates_command_, GROUP_UI, GROUP_PASSWORD);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
- EXPECT_TRUE(status->HasConflictingUpdates())
- << "Updates that can't be decrypted should trigger the syncer to have "
- << "conflicting updates.";
- EXPECT_EQ(0, status->num_simple_conflicts())
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_TRUE(status.HasConflictingUpdates())
+ << "Updates that can't be decrypted should trigger the syncer to have "
+ << "conflicting updates.";
+ EXPECT_EQ(0, status.num_simple_conflicts())
<< "Updates that can't be decrypted should not be in regular conflict";
- EXPECT_EQ(3, status->num_encryption_conflicts())
+ EXPECT_EQ(3, status.num_encryption_conflicts())
<< "Updates that can't be decrypted should be in encryption conflict";
- {
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_UI);
- ASSERT_TRUE(status->update_progress());
- EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize())
- << "All updates should have been attempted";
- EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount())
- << "No update that can't be decrypted should be applied";
- }
- {
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD);
- ASSERT_TRUE(status->update_progress());
- EXPECT_EQ(1, status->update_progress()->AppliedUpdatesSize())
- << "All updates should have been attempted";
- EXPECT_EQ(0, status->update_progress()->SuccessfullyAppliedUpdateCount())
- << "No update that can't be decrypted should be applied";
- }
+ EXPECT_EQ(0, status.num_updates_applied())
+ << "No update that can't be decrypted should be applied";
}
TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) {
@@ -468,25 +421,18 @@ TEST_F(ApplyUpdatesCommandTest, SomeUndecryptablePassword) {
ExpectGroupToChange(apply_updates_command_, GROUP_PASSWORD);
apply_updates_command_.ExecuteImpl(session());
- sessions::StatusController* status = session()->mutable_status_controller();
- EXPECT_TRUE(status->HasConflictingUpdates())
- << "Updates that can't be decrypted should trigger the syncer to have "
- << "conflicting updates.";
- {
- EXPECT_EQ(0, status->num_simple_conflicts())
- << "The updates that can't be decrypted should not be in regular "
- << "conflict";
- EXPECT_EQ(1, status->num_encryption_conflicts())
- << "The updates that can't be decrypted should be in encryption "
- << "conflict";
-
- sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSWORD);
- ASSERT_TRUE(status->update_progress());
- EXPECT_EQ(2, status->update_progress()->AppliedUpdatesSize())
- << "All updates should have been attempted";
- EXPECT_EQ(1, status->update_progress()->SuccessfullyAppliedUpdateCount())
- << "The undecryptable password update shouldn't be applied";
- }
+ const sessions::StatusController& status = session()->status_controller();
+ EXPECT_TRUE(status.HasConflictingUpdates())
+ << "Updates that can't be decrypted should trigger the syncer to have "
+ << "conflicting updates.";
+ EXPECT_EQ(0, status.num_simple_conflicts())
+ << "The updates that can't be decrypted should not be in regular "
+ << "conflict";
+ EXPECT_EQ(1, status.num_encryption_conflicts())
+ << "The updates that can't be decrypted should be in encryption "
+ << "conflict";
+ EXPECT_EQ(1, status.num_updates_applied())
+ << "The undecryptable password update shouldn't be applied";
}
} // namespace syncer
diff --git a/sync/engine/process_updates_command.cc b/sync/engine/process_updates_command.cc
index 22d465c..15a14cb 100644
--- a/sync/engine/process_updates_command.cc
+++ b/sync/engine/process_updates_command.cc
@@ -30,7 +30,6 @@ namespace syncer {
using sessions::SyncSession;
using sessions::StatusController;
-using sessions::UpdateProgress;
using syncable::GET_BY_ID;
@@ -141,7 +140,6 @@ SyncerError ProcessUpdatesCommand::ModelChangingExecuteImpl(
VerifyResult verify_result = VerifyUpdate(&trans, update,
requested_types,
session->routing_info());
- status->mutable_update_progress()->AddVerifyResult(verify_result, update);
status->increment_num_updates_downloaded_by(1);
if (!UpdateContainsNewVersion(&trans, update))
status->increment_num_reflected_updates_downloaded_by(1);
@@ -158,7 +156,6 @@ SyncerError ProcessUpdatesCommand::ModelChangingExecuteImpl(
process_result == SUCCESS_STORED);
}
- status->mutable_update_progress()->ClearVerifiedUpdates();
return SYNCER_OK;
}
diff --git a/sync/engine/update_applicator.cc b/sync/engine/update_applicator.cc
index cb09fc7..541b68c 100644
--- a/sync/engine/update_applicator.cc
+++ b/sync/engine/update_applicator.cc
@@ -25,8 +25,7 @@ UpdateApplicator::UpdateApplicator(Cryptographer* cryptographer,
ModelSafeGroup group_filter)
: cryptographer_(cryptographer),
group_filter_(group_filter),
- routing_info_(routes),
- application_results_() {
+ routing_info_(routes) {
}
UpdateApplicator::~UpdateApplicator() {
@@ -48,6 +47,9 @@ void UpdateApplicator::AttemptApplications(
const std::vector<int64>& handles,
sessions::StatusController* status) {
std::vector<int64> to_apply = handles;
+ std::set<syncable::Id>* simple_conflict_ids =
+ status->mutable_simple_conflict_ids();
+
DVLOG(1) << "UpdateApplicator running over " << to_apply.size() << " items.";
while (!to_apply.empty()) {
std::vector<int64> to_reapply;
@@ -64,18 +66,15 @@ void UpdateApplicator::AttemptApplications(
switch (result) {
case SUCCESS:
- application_results_.AddSuccess(entry.Get(ID));
status->increment_num_updates_applied();
break;
case CONFLICT_SIMPLE:
- application_results_.AddSimpleConflict(entry.Get(ID));
+ simple_conflict_ids->insert(entry.Get(ID));
break;
case CONFLICT_ENCRYPTION:
- application_results_.AddEncryptionConflict(entry.Get(ID));
status->increment_num_encryption_conflicts();
break;
case CONFLICT_HIERARCHY:
- application_results_.AddHierarchyConflict(entry.Get(ID));
// The decision to classify these as hierarchy conflcits is tentative.
// If we make any progress this round, we'll clear the hierarchy
// conflict count and attempt to reapply these updates.
@@ -96,7 +95,6 @@ void UpdateApplicator::AttemptApplications(
// We made some progress, so prepare for what might be another iteration.
// If everything went well, to_reapply will be empty and we'll break out on
// the while condition.
- application_results_.ClearHierarchyConflicts();
to_apply.swap(to_reapply);
to_reapply.clear();
}
@@ -121,61 +119,4 @@ bool UpdateApplicator::SkipUpdate(const syncable::Entry& entry) {
return false;
}
-void UpdateApplicator::SaveProgressIntoSessionState(
- std::set<syncable::Id>* simple_conflict_ids,
- sessions::UpdateProgress* update_progress) {
- application_results_.SaveProgress(simple_conflict_ids, update_progress);
-}
-
-UpdateApplicator::ResultTracker::ResultTracker() {
-}
-
-UpdateApplicator::ResultTracker::~ResultTracker() {
-}
-
-void UpdateApplicator::ResultTracker::AddSimpleConflict(syncable::Id id) {
- conflicting_ids_.insert(id);
-}
-
-void UpdateApplicator::ResultTracker::AddEncryptionConflict(syncable::Id id) {
- encryption_conflict_ids_.insert(id);
-}
-
-void UpdateApplicator::ResultTracker::AddHierarchyConflict(syncable::Id id) {
- hierarchy_conflict_ids_.insert(id);
-}
-
-void UpdateApplicator::ResultTracker::AddSuccess(syncable::Id id) {
- successful_ids_.insert(id);
-}
-
-void UpdateApplicator::ResultTracker::SaveProgress(
- std::set<syncable::Id>* simple_conflict_ids,
- sessions::UpdateProgress* update_progress) {
- std::set<syncable::Id>::const_iterator i;
- *simple_conflict_ids = conflicting_ids_;
- for (i = conflicting_ids_.begin(); i != conflicting_ids_.end(); ++i) {
- update_progress->AddAppliedUpdate(CONFLICT_SIMPLE, *i);
- }
- for (i = encryption_conflict_ids_.begin();
- i != encryption_conflict_ids_.end(); ++i) {
- update_progress->AddAppliedUpdate(CONFLICT_ENCRYPTION, *i);
- }
- for (i = hierarchy_conflict_ids_.begin();
- i != hierarchy_conflict_ids_.end(); ++i) {
- update_progress->AddAppliedUpdate(CONFLICT_HIERARCHY, *i);
- }
- for (i = successful_ids_.begin(); i != successful_ids_.end(); ++i) {
- update_progress->AddAppliedUpdate(SUCCESS, *i);
- }
-}
-
-void UpdateApplicator::ResultTracker::ClearHierarchyConflicts() {
- hierarchy_conflict_ids_.clear();
-}
-
-bool UpdateApplicator::ResultTracker::no_conflicts() const {
- return conflicting_ids_.empty();
-}
-
} // namespace syncer
diff --git a/sync/engine/update_applicator.h b/sync/engine/update_applicator.h
index 290a76c..c5b27a2 100644
--- a/sync/engine/update_applicator.h
+++ b/sync/engine/update_applicator.h
@@ -23,7 +23,6 @@ namespace syncer {
namespace sessions {
class StatusController;
-class UpdateProgress;
}
namespace syncable {
@@ -48,38 +47,7 @@ class UpdateApplicator {
const std::vector<int64>& handles,
sessions::StatusController* status);
- // This class does not automatically save its progress into the
- // SyncSession -- to get that to happen, call this method after update
- // application is finished (i.e., when AttemptOneAllocation stops returning
- // true).
- void SaveProgressIntoSessionState(
- std::set<syncable::Id>* simple_conflict_ids,
- sessions::UpdateProgress* update_progress);
-
private:
- // Track the status of all applications.
- class ResultTracker {
- public:
- explicit ResultTracker();
- virtual ~ResultTracker();
- void AddSimpleConflict(syncable::Id);
- void AddEncryptionConflict(syncable::Id);
- void AddHierarchyConflict(syncable::Id);
- void AddSuccess(syncable::Id);
- void SaveProgress(std::set<syncable::Id>* simple_conflict_ids,
- sessions::UpdateProgress* update_progress);
- void ClearHierarchyConflicts();
-
- // Returns true iff conflicting_ids_ is empty. Does not check
- // encryption_conflict_ids_.
- bool no_conflicts() const;
- private:
- std::set<syncable::Id> conflicting_ids_;
- std::set<syncable::Id> successful_ids_;
- std::set<syncable::Id> encryption_conflict_ids_;
- std::set<syncable::Id> hierarchy_conflict_ids_;
- };
-
// If true, AttemptOneApplication will skip over |entry| and return true.
bool SkipUpdate(const syncable::Entry& entry);
@@ -90,9 +58,6 @@ class UpdateApplicator {
const ModelSafeRoutingInfo routing_info_;
- // Track the result of the attempts to update applications.
- ResultTracker application_results_;
-
DISALLOW_COPY_AND_ASSIGN(UpdateApplicator);
};
diff --git a/sync/sessions/session_state.cc b/sync/sessions/session_state.cc
index f5d1709..a08b093 100644
--- a/sync/sessions/session_state.cc
+++ b/sync/sessions/session_state.cc
@@ -16,63 +16,6 @@ using std::vector;
namespace syncer {
namespace sessions {
-UpdateProgress::UpdateProgress() {}
-
-UpdateProgress::~UpdateProgress() {}
-
-void UpdateProgress::AddVerifyResult(const VerifyResult& verify_result,
- const sync_pb::SyncEntity& entity) {
- verified_updates_.push_back(std::make_pair(verify_result, entity));
-}
-
-void UpdateProgress::AddAppliedUpdate(const UpdateAttemptResponse& response,
- const syncable::Id& id) {
- applied_updates_.push_back(std::make_pair(response, id));
-}
-
-std::vector<AppliedUpdate>::iterator UpdateProgress::AppliedUpdatesBegin() {
- return applied_updates_.begin();
-}
-
-std::vector<VerifiedUpdate>::const_iterator
-UpdateProgress::VerifiedUpdatesBegin() const {
- return verified_updates_.begin();
-}
-
-std::vector<AppliedUpdate>::const_iterator
-UpdateProgress::AppliedUpdatesEnd() const {
- return applied_updates_.end();
-}
-
-std::vector<VerifiedUpdate>::const_iterator
-UpdateProgress::VerifiedUpdatesEnd() const {
- return verified_updates_.end();
-}
-
-int UpdateProgress::SuccessfullyAppliedUpdateCount() const {
- int count = 0;
- for (std::vector<AppliedUpdate>::const_iterator it =
- applied_updates_.begin();
- it != applied_updates_.end();
- ++it) {
- if (it->first == SUCCESS)
- count++;
- }
- return count;
-}
-
-// Returns true if at least one update application failed due to a conflict
-// during this sync cycle.
-bool UpdateProgress::HasConflictingUpdates() const {
- std::vector<AppliedUpdate>::const_iterator it;
- for (it = applied_updates_.begin(); it != applied_updates_.end(); ++it) {
- if (it->first != SUCCESS) {
- return true;
- }
- }
- return false;
-}
-
PerModelSafeGroupState::PerModelSafeGroupState() {
}
diff --git a/sync/sessions/session_state.h b/sync/sessions/session_state.h
index 548b4ed..4ef6860 100644
--- a/sync/sessions/session_state.h
+++ b/sync/sessions/session_state.h
@@ -13,69 +13,17 @@
#define SYNC_SESSIONS_SESSION_STATE_H_
#include <set>
-#include <vector>
-#include "sync/engine/syncer_types.h"
-#include "sync/protocol/sync.pb.h"
#include "sync/syncable/syncable_id.h"
namespace syncer {
namespace sessions {
-typedef std::pair<VerifyResult, sync_pb::SyncEntity> VerifiedUpdate;
-typedef std::pair<UpdateAttemptResponse, syncable::Id> AppliedUpdate;
-
-// Tracks update application and verification.
-class UpdateProgress {
- public:
- UpdateProgress();
- ~UpdateProgress();
-
- void AddVerifyResult(const VerifyResult& verify_result,
- const sync_pb::SyncEntity& entity);
-
- // Log a successful or failing update attempt.
- void AddAppliedUpdate(const UpdateAttemptResponse& response,
- const syncable::Id& id);
-
- // Various iterators.
- std::vector<AppliedUpdate>::iterator AppliedUpdatesBegin();
- std::vector<VerifiedUpdate>::const_iterator VerifiedUpdatesBegin() const;
- std::vector<AppliedUpdate>::const_iterator AppliedUpdatesEnd() const;
- std::vector<VerifiedUpdate>::const_iterator VerifiedUpdatesEnd() const;
-
- // Returns the number of update application attempts. This includes both
- // failures and successes.
- int AppliedUpdatesSize() const { return applied_updates_.size(); }
- int VerifiedUpdatesSize() const { return verified_updates_.size(); }
- bool HasVerifiedUpdates() const { return !verified_updates_.empty(); }
- bool HasAppliedUpdates() const { return !applied_updates_.empty(); }
- void ClearVerifiedUpdates() { verified_updates_.clear(); }
-
- // Count the number of successful update applications that have happend this
- // cycle. Note that if an item is successfully applied twice, it will be
- // double counted here.
- int SuccessfullyAppliedUpdateCount() const;
-
- // Returns true if at least one update application failed due to a conflict
- // during this sync cycle.
- bool HasConflictingUpdates() const;
-
- private:
- // Container for updates that passed verification.
- std::vector<VerifiedUpdate> verified_updates_;
-
- // Stores the result of the various ApplyUpdate attempts we've made.
- // May contain duplicate entries.
- std::vector<AppliedUpdate> applied_updates_;
-};
-
// Grouping of all state that applies to a single ModelSafeGroup.
struct PerModelSafeGroupState {
explicit PerModelSafeGroupState();
~PerModelSafeGroupState();
- UpdateProgress update_progress;
std::set<syncable::Id> simple_conflict_ids;
};
diff --git a/sync/sessions/status_controller.cc b/sync/sessions/status_controller.cc
index 93a37f1..f47b085 100644
--- a/sync/sessions/status_controller.cc
+++ b/sync/sessions/status_controller.cc
@@ -22,17 +22,6 @@ StatusController::StatusController(const ModelSafeRoutingInfo& routes)
StatusController::~StatusController() {}
-const UpdateProgress* StatusController::update_progress() const {
- const PerModelSafeGroupState* state =
- GetModelSafeGroupState(true, group_restriction_);
- return state ? &state->update_progress : NULL;
-}
-
-UpdateProgress* StatusController::mutable_update_progress() {
- return &GetOrCreateModelSafeGroupState(
- true, group_restriction_)->update_progress;
-}
-
const std::set<syncable::Id>* StatusController::simple_conflict_ids() const {
const PerModelSafeGroupState* state =
GetModelSafeGroupState(true, group_restriction_);
@@ -51,18 +40,6 @@ const std::set<syncable::Id>*
return state ? &state->simple_conflict_ids : NULL;
}
-const UpdateProgress* StatusController::GetUnrestrictedUpdateProgress(
- ModelSafeGroup group) const {
- const PerModelSafeGroupState* state = GetModelSafeGroupState(false, group);
- return state ? &state->update_progress : NULL;
-}
-
-UpdateProgress*
- StatusController::GetUnrestrictedMutableUpdateProgressForTest(
- ModelSafeGroup group) {
- return &GetOrCreateModelSafeGroupState(false, group)->update_progress;
-}
-
const PerModelSafeGroupState* StatusController::GetModelSafeGroupState(
bool restrict, ModelSafeGroup group) const {
DCHECK_EQ(restrict, group_restriction_in_effect_);
@@ -187,15 +164,11 @@ int64 StatusController::CountUpdates() const {
}
bool StatusController::HasConflictingUpdates() const {
- DCHECK(!group_restriction_in_effect_)
- << "HasConflictingUpdates applies to all ModelSafeGroups";
- std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
- per_model_group_.begin();
- for (; it != per_model_group_.end(); ++it) {
- if (it->second->update_progress.HasConflictingUpdates())
- return true;
- }
- return false;
+ return TotalNumConflictingItems() > 0;
+}
+
+int StatusController::num_updates_applied() const {
+ return model_neutral_.num_updates_applied;
}
int StatusController::num_encryption_conflicts() const {
diff --git a/sync/sessions/status_controller.h b/sync/sessions/status_controller.h
index c18fc7d..1465dbf 100644
--- a/sync/sessions/status_controller.h
+++ b/sync/sessions/status_controller.h
@@ -55,14 +55,8 @@ class StatusController {
// auto-create.
const std::set<syncable::Id>* simple_conflict_ids() const;
std::set<syncable::Id>* mutable_simple_conflict_ids();
- const UpdateProgress* update_progress() const;
- UpdateProgress* mutable_update_progress();
const std::set<syncable::Id>* GetUnrestrictedSimpleConflictIds(
ModelSafeGroup group) const;
- const UpdateProgress* GetUnrestrictedUpdateProgress(
- ModelSafeGroup group) const;
- UpdateProgress* GetUnrestrictedMutableUpdateProgressForTest(
- ModelSafeGroup group);
// ClientToServer messages.
const ModelTypeSet updates_request_types() const {
@@ -110,6 +104,9 @@ class StatusController {
// Aggregate sum of all conflicting items over all conflict types.
int TotalNumConflictingItems() const;
+ // Number of successfully applied updates.
+ int num_updates_applied() const;
+
// Returns the number of updates received from the sync server.
int64 CountUpdates() const;
diff --git a/sync/sessions/status_controller_unittest.cc b/sync/sessions/status_controller_unittest.cc
index 619e1fa..3e5143b 100644
--- a/sync/sessions/status_controller_unittest.cc
+++ b/sync/sessions/status_controller_unittest.cc
@@ -45,37 +45,22 @@ TEST_F(StatusControllerTest, ReadYourWrites) {
TEST_F(StatusControllerTest, HasConflictingUpdates) {
StatusController status(routes_);
EXPECT_FALSE(status.HasConflictingUpdates());
+
{
ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
- EXPECT_FALSE(status.update_progress());
- status.mutable_update_progress()->AddAppliedUpdate(SUCCESS,
- syncable::Id());
- status.mutable_update_progress()->AddAppliedUpdate(CONFLICT_SIMPLE,
- syncable::Id());
- EXPECT_TRUE(status.update_progress()->HasConflictingUpdates());
+ status.increment_num_updates_applied();
+ status.mutable_simple_conflict_ids()->insert(syncable::Id());
}
EXPECT_TRUE(status.HasConflictingUpdates());
-
- {
- ScopedModelSafeGroupRestriction r(&status, GROUP_PASSIVE);
- EXPECT_FALSE(status.update_progress());
- }
}
TEST_F(StatusControllerTest, HasConflictingUpdates_NonBlockingUpdates) {
StatusController status(routes_);
EXPECT_FALSE(status.HasConflictingUpdates());
- {
- ScopedModelSafeGroupRestriction r(&status, GROUP_UI);
- EXPECT_FALSE(status.update_progress());
- status.mutable_update_progress()->AddAppliedUpdate(SUCCESS,
- syncable::Id());
- status.mutable_update_progress()->AddAppliedUpdate(CONFLICT_HIERARCHY,
- syncable::Id());
- EXPECT_TRUE(status.update_progress()->HasConflictingUpdates());
- }
+ status.increment_num_updates_applied();
+ status.increment_num_encryption_conflicts();
EXPECT_TRUE(status.HasConflictingUpdates());
}
@@ -116,9 +101,6 @@ TEST_F(StatusControllerTest, TotalNumConflictingItems) {
// Basic test that non group-restricted state accessors don't cause violations.
TEST_F(StatusControllerTest, Unrestricted) {
StatusController status(routes_);
- const UpdateProgress* progress =
- status.GetUnrestrictedUpdateProgress(GROUP_UI);
- EXPECT_FALSE(progress);
status.model_neutral_state();
status.download_updates_succeeded();
status.ServerSaysNothingMoreToDownload();