summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 19:32:28 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 19:32:28 +0000
commit90ce61b5448c93e52a34b71535d86605a4f7f90d (patch)
tree357c076b80e6bf248511878c8cde5b262466158f /chrome/browser
parent7500c55e2fc2219e50e3b6b40e6c8e3ed3820d20 (diff)
downloadchromium_src-90ce61b5448c93e52a34b71535d86605a4f7f90d.zip
chromium_src-90ce61b5448c93e52a34b71535d86605a4f7f90d.tar.gz
chromium_src-90ce61b5448c93e52a34b71535d86605a4f7f90d.tar.bz2
[Sync] Convert SyncSessionSnapshot to a copy-able class.
Previously it was an immutable struct that was passed around by making dynamic allocations and passing pointers. We now just have a class with only getters and no setters, but support for default copy and assign. This cleans up some code and makes some future work easier to pass snapshots around. BUG=none TEST=sync_unit_tests Review URL: http://codereview.chromium.org/10197004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/sync/backend_migrator.cc1
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc23
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h11
-rw-r--r--chrome/browser/sync/profile_sync_service.cc4
-rw-r--r--chrome/browser/sync/profile_sync_service.h4
-rw-r--r--chrome/browser/sync/profile_sync_service_harness.cc109
-rw-r--r--chrome/browser/sync/profile_sync_service_harness.h12
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.h2
-rw-r--r--chrome/browser/sync/retry_verifier.cc12
-rw-r--r--chrome/browser/sync/retry_verifier.h7
-rw-r--r--chrome/browser/sync/sync_ui_util.cc75
-rw-r--r--chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc12
-rw-r--r--chrome/browser/sync/test_profile_sync_service.cc8
13 files changed, 129 insertions, 151 deletions
diff --git a/chrome/browser/sync/backend_migrator.cc b/chrome/browser/sync/backend_migrator.cc
index 3894bbd..e8eb407 100644
--- a/chrome/browser/sync/backend_migrator.cc
+++ b/chrome/browser/sync/backend_migrator.cc
@@ -20,7 +20,6 @@ using syncable::ModelTypeSet;
namespace browser_sync {
-using sessions::SyncSessionSnapshot;
using syncable::ModelTypeToString;
MigrationObserver::~MigrationObserver() {}
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index 0d59793..42aed59 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -45,7 +45,6 @@
#include "sync/notifier/sync_notifier.h"
#include "sync/protocol/encryption.pb.h"
#include "sync/protocol/sync.pb.h"
-#include "sync/sessions/session_state.h"
#include "sync/util/nigori.h"
static const int kSaveChangesIntervalSeconds = 10;
@@ -81,7 +80,7 @@ class SyncBackendHost::Core
// traffic controller here, forwarding incoming messages to appropriate
// landing threads.
virtual void OnSyncCycleCompleted(
- const sessions::SyncSessionSnapshot* snapshot) OVERRIDE;
+ const sessions::SyncSessionSnapshot& snapshot) OVERRIDE;
virtual void OnInitializationComplete(
const WeakHandle<JsBackend>& js_backend,
bool success) OVERRIDE;
@@ -614,8 +613,8 @@ SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() {
return core_->sync_manager()->GetDetailedStatus();
}
-const SyncSessionSnapshot* SyncBackendHost::GetLastSessionSnapshot() const {
- return last_snapshot_.get();
+SyncSessionSnapshot SyncBackendHost::GetLastSessionSnapshot() const {
+ return last_snapshot_;
}
bool SyncBackendHost::HasUnsyncedItems() const {
@@ -657,17 +656,17 @@ void SyncBackendHost::InitCore(const DoInitializeOptions& options) {
}
void SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop(
- SyncSessionSnapshot* snapshot) {
+ const SyncSessionSnapshot& snapshot) {
if (!frontend_)
return;
DCHECK_EQ(MessageLoop::current(), frontend_loop_);
- last_snapshot_.reset(snapshot);
+ last_snapshot_ = snapshot;
- SDVLOG(1) << "Got snapshot " << snapshot->ToString();
+ SDVLOG(1) << "Got snapshot " << snapshot.ToString();
const syncable::ModelTypeSet to_migrate =
- snapshot->syncer_status.types_needing_local_migration;
+ snapshot.syncer_status().types_needing_local_migration;
if (!to_migrate.Empty())
frontend_->OnMigrationNeededForTypes(to_migrate);
@@ -686,7 +685,7 @@ void SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop(
pending_download_state_->added_types;
DCHECK(types_to_add.HasAll(added_types));
const syncable::ModelTypeSet initial_sync_ended =
- snapshot->initial_sync_ended;
+ snapshot.initial_sync_ended();
const syncable::ModelTypeSet failed_configuration_types =
Difference(added_types, initial_sync_ended);
SDVLOG(1)
@@ -698,7 +697,7 @@ void SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop(
<< syncable::ModelTypeSetToString(failed_configuration_types);
if (!failed_configuration_types.Empty() &&
- snapshot->retry_scheduled) {
+ snapshot.retry_scheduled()) {
// Inform the caller that download failed but we are retrying.
if (!pending_download_state_->retry_in_progress) {
pending_download_state_->retry_callback.Run();
@@ -864,14 +863,14 @@ SyncBackendHost::PendingConfigureDataTypesState::
~PendingConfigureDataTypesState() {}
void SyncBackendHost::Core::OnSyncCycleCompleted(
- const SyncSessionSnapshot* snapshot) {
+ const SyncSessionSnapshot& snapshot) {
if (!sync_loop_)
return;
DCHECK_EQ(MessageLoop::current(), sync_loop_);
host_.Call(
FROM_HERE,
&SyncBackendHost::HandleSyncCycleCompletedOnFrontendLoop,
- new SyncSessionSnapshot(*snapshot));
+ snapshot);
}
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index 3073d6d..691586a 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -26,6 +26,7 @@
#include "sync/notifier/sync_notifier_factory.h"
#include "sync/protocol/encryption.pb.h"
#include "sync/protocol/sync_protocol_error.h"
+#include "sync/sessions/session_state.h"
#include "sync/syncable/model_type.h"
#include "sync/util/report_unrecoverable_error_function.h"
#include "sync/util/unrecoverable_error_handler.h"
@@ -36,10 +37,6 @@ class Profile;
namespace browser_sync {
-namespace sessions {
-struct SyncSessionSnapshot;
-}
-
class ChangeProcessor;
class JsBackend;
class JsEventHandler;
@@ -256,7 +253,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
// Called from any thread to obtain current status information in detailed or
// summarized form.
Status GetDetailedStatus();
- const sessions::SyncSessionSnapshot* GetLastSessionSnapshot() const;
+ sessions::SyncSessionSnapshot GetLastSessionSnapshot() const;
// Determines if the underlying sync engine has made any local changes to
// items that have not yet been synced with the server.
@@ -328,7 +325,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
// Called from Core::OnSyncCycleCompleted to handle updating frontend
// thread components.
void HandleSyncCycleCompletedOnFrontendLoop(
- sessions::SyncSessionSnapshot* snapshot);
+ const sessions::SyncSessionSnapshot& snapshot);
// Called to finish the job of ConfigureDataTypes once the syncer is in
// configuration mode.
@@ -515,7 +512,7 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
sync_pb::EncryptedData cached_pending_keys_;
// UI-thread cache of the last SyncSessionSnapshot received from syncapi.
- scoped_ptr<sessions::SyncSessionSnapshot> last_snapshot_;
+ sessions::SyncSessionSnapshot last_snapshot_;
DISALLOW_COPY_AND_ASSIGN(SyncBackendHost);
};
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 40910f0..5832936 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -1233,13 +1233,13 @@ sync_api::UserShare* ProfileSyncService::GetUserShare() const {
return NULL;
}
-const browser_sync::sessions::SyncSessionSnapshot*
+browser_sync::sessions::SyncSessionSnapshot
ProfileSyncService::GetLastSessionSnapshot() const {
if (backend_.get() && backend_initialized_) {
return backend_->GetLastSessionSnapshot();
}
NOTREACHED();
- return NULL;
+ return browser_sync::sessions::SyncSessionSnapshot();
}
bool ProfileSyncService::HasUnsyncedItems() const {
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 0abf55d..3a779ba 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -48,7 +48,7 @@ class ChangeProcessor;
class DataTypeManager;
class JsController;
class SessionModelAssociator;
-namespace sessions { struct SyncSessionSnapshot; }
+namespace sessions { class SyncSessionSnapshot; }
}
namespace sync_api {
@@ -360,7 +360,7 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// ProfileSyncServiceHarness. Figure out a different way to expose
// this info to that class, and remove these functions.
- virtual const browser_sync::sessions::SyncSessionSnapshot*
+ virtual browser_sync::sessions::SyncSessionSnapshot
GetLastSessionSnapshot() const;
// Returns whether or not the underlying sync engine has made any
diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc
index d7bdb1c..d4073b6 100644
--- a/chrome/browser/sync/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/profile_sync_service_harness.cc
@@ -337,7 +337,7 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() {
// TODO(rlarocque): Figure out a less brittle way of detecting this.
if (IsTypeEncrypted(waiting_for_encryption_type_) &&
IsFullySynced() &&
- GetLastSessionSnapshot()->num_encryption_conflicts == 0) {
+ GetLastSessionSnapshot().num_encryption_conflicts() == 0) {
// Encryption is now complete for the the type in which we were waiting.
SignalStateCompleteWithNextState(FULLY_SYNCED);
break;
@@ -363,10 +363,8 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() {
case WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION: {
DVLOG(1) << GetClientInfoString(
"WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION");
- const browser_sync::sessions::SyncSessionSnapshot *snap =
- GetLastSessionSnapshot();
- CHECK(snap);
- retry_verifier_.VerifyRetryInterval(*snap);
+ const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
+ retry_verifier_.VerifyRetryInterval(snap);
if (retry_verifier_.done()) {
// Retry verifier is done verifying exponential backoff.
SignalStateCompleteWithNextState(WAITING_FOR_NOTHING);
@@ -580,10 +578,8 @@ bool ProfileSyncServiceHarness::AwaitSyncDisabled(const std::string& reason) {
}
bool ProfileSyncServiceHarness::AwaitExponentialBackoffVerification() {
- const browser_sync::sessions::SyncSessionSnapshot *snap =
- GetLastSessionSnapshot();
- CHECK(snap);
- retry_verifier_.Initialize(*snap);
+ const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
+ retry_verifier_.Initialize(snap);
wait_state_ = WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION;
AwaitStatusChangeWithTimeout(kExponentialBackoffVerificationTimeoutMs,
"Verify Exponential backoff");
@@ -754,14 +750,13 @@ ProfileSyncService::Status ProfileSyncServiceHarness::GetStatus() {
// We use this function to share code between IsFullySynced and IsDataSynced
// while ensuring that all conditions are evaluated using on the same snapshot.
bool ProfileSyncServiceHarness::IsDataSyncedImpl(
- const browser_sync::sessions::SyncSessionSnapshot *snap) {
- return snap &&
- snap->num_simple_conflicts == 0 &&
- ServiceIsPushingChanges() &&
- GetStatus().notifications_enabled &&
- !service()->HasUnsyncedItems() &&
- !snap->has_more_to_sync &&
- !HasPendingBackendMigration();
+ const SyncSessionSnapshot& snap) {
+ return snap.num_simple_conflicts() == 0 &&
+ ServiceIsPushingChanges() &&
+ GetStatus().notifications_enabled &&
+ !service()->HasUnsyncedItems() &&
+ !snap.has_more_to_sync() &&
+ !HasPendingBackendMigration();
}
bool ProfileSyncServiceHarness::IsDataSynced() {
@@ -770,7 +765,7 @@ bool ProfileSyncServiceHarness::IsDataSynced() {
return false;
}
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
+ const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
bool is_data_synced = IsDataSyncedImpl(snap);
DVLOG(1) << GetClientInfoString(
@@ -783,11 +778,11 @@ bool ProfileSyncServiceHarness::IsFullySynced() {
DVLOG(1) << GetClientInfoString("IsFullySynced: false");
return false;
}
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
- // snap->unsynced_count == 0 is a fairly reliable indicator of whether or not
+ const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
+ // snap.unsynced_count() == 0 is a fairly reliable indicator of whether or not
// our timestamp is in sync with the server.
bool is_fully_synced = IsDataSyncedImpl(snap) &&
- snap->unsynced_count == 0;
+ snap.unsynced_count() == 0;
DVLOG(1) << GetClientInfoString(
is_fully_synced ? "IsFullySynced: true" : "IsFullySynced: false");
@@ -856,13 +851,12 @@ bool ProfileSyncServiceHarness::MatchesOtherClient(
return true;
}
-const SyncSessionSnapshot*
- ProfileSyncServiceHarness::GetLastSessionSnapshot() const {
+SyncSessionSnapshot ProfileSyncServiceHarness::GetLastSessionSnapshot() const {
DCHECK(service_ != NULL) << "Sync service has not yet been set up.";
if (service_->sync_initialized()) {
return service_->GetLastSessionSnapshot();
}
- return NULL;
+ return SyncSessionSnapshot();
}
bool ProfileSyncServiceHarness::EnableSyncForDatatype(
@@ -975,9 +969,8 @@ bool ProfileSyncServiceHarness::DisableSyncForAllDatatypes() {
std::string ProfileSyncServiceHarness::GetUpdatedTimestamp(
syncable::ModelType model_type) {
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
- DCHECK(snap != NULL) << "GetUpdatedTimestamp(): Sync snapshot is NULL.";
- return snap->download_progress_markers[model_type];
+ const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
+ return snap.download_progress_markers()[model_type];
}
std::string ProfileSyncServiceHarness::GetClientInfoString(
@@ -985,38 +978,34 @@ std::string ProfileSyncServiceHarness::GetClientInfoString(
std::stringstream os;
os << profile_debug_name_ << ": " << message << ": ";
if (service()) {
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
+ const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
const ProfileSyncService::Status& status = GetStatus();
- if (snap) {
- // Capture select info from the sync session snapshot and syncer status.
- os << "has_more_to_sync: "
- << snap->has_more_to_sync
- << ", has_unsynced_items: "
- << service()->HasUnsyncedItems()
- << ", unsynced_count: "
- << snap->unsynced_count
- << ", encryption conflicts: "
- << snap->num_encryption_conflicts
- << ", hierarchy conflicts: "
- << snap->num_hierarchy_conflicts
- << ", simple conflicts: "
- << snap->num_simple_conflicts
- << ", server conflicts: "
- << snap->num_server_conflicts
- << ", num_updates_downloaded : "
- << snap->syncer_status.num_updates_downloaded_total
- << ", passphrase_required_reason: "
- << sync_api::PassphraseRequiredReasonToString(
- service()->passphrase_required_reason())
- << ", notifications_enabled: "
- << status.notifications_enabled
- << ", service_is_pushing_changes: "
- << ServiceIsPushingChanges()
- << ", has_pending_backend_migration: "
- << HasPendingBackendMigration();
- } else {
- os << "Sync session snapshot not available";
- }
+ // Capture select info from the sync session snapshot and syncer status.
+ os << "has_more_to_sync: "
+ << snap.has_more_to_sync()
+ << ", has_unsynced_items: "
+ << service()->HasUnsyncedItems()
+ << ", unsynced_count: "
+ << snap.unsynced_count()
+ << ", encryption conflicts: "
+ << snap.num_encryption_conflicts()
+ << ", hierarchy conflicts: "
+ << snap.num_hierarchy_conflicts()
+ << ", simple conflicts: "
+ << snap.num_simple_conflicts()
+ << ", server conflicts: "
+ << snap.num_server_conflicts()
+ << ", num_updates_downloaded : "
+ << snap.syncer_status().num_updates_downloaded_total
+ << ", passphrase_required_reason: "
+ << sync_api::PassphraseRequiredReasonToString(
+ service()->passphrase_required_reason())
+ << ", notifications_enabled: "
+ << status.notifications_enabled
+ << ", service_is_pushing_changes: "
+ << ServiceIsPushingChanges()
+ << ", has_pending_backend_migration: "
+ << HasPendingBackendMigration();
} else {
os << "Sync service not available";
}
@@ -1052,7 +1041,7 @@ bool ProfileSyncServiceHarness::WaitForTypeEncryption(
// TODO(rlarocque): Figure out a less brittle way of detecting this.
if (IsTypeEncrypted(type) &&
IsFullySynced() &&
- GetLastSessionSnapshot()->num_encryption_conflicts == 0) {
+ GetLastSessionSnapshot().num_encryption_conflicts() == 0) {
// Encryption is already complete for |type|; do not wait.
return true;
}
@@ -1092,7 +1081,7 @@ bool ProfileSyncServiceHarness::IsTypePreferred(syncable::ModelType type) {
}
size_t ProfileSyncServiceHarness::GetNumEntries() const {
- return GetLastSessionSnapshot()->num_entries;
+ return GetLastSessionSnapshot().num_entries();
}
size_t ProfileSyncServiceHarness::GetNumDatatypes() const {
diff --git a/chrome/browser/sync/profile_sync_service_harness.h b/chrome/browser/sync/profile_sync_service_harness.h
index 48de1d4..7ae069c 100644
--- a/chrome/browser/sync/profile_sync_service_harness.h
+++ b/chrome/browser/sync/profile_sync_service_harness.h
@@ -20,9 +20,9 @@
class Profile;
namespace browser_sync {
- namespace sessions {
- struct SyncSessionSnapshot;
- }
+namespace sessions {
+class SyncSessionSnapshot;
+}
}
// An instance of this class is basically our notion of a "sync client" for
@@ -161,8 +161,7 @@ class ProfileSyncServiceHarness
bool DisableSyncForAllDatatypes();
// Returns a snapshot of the current sync session.
- const browser_sync::sessions::SyncSessionSnapshot*
- GetLastSessionSnapshot() const;
+ browser_sync::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const;
// Encrypt the datatype |type|. This method will block while the sync backend
// host performs the encryption or a timeout is reached.
@@ -290,7 +289,8 @@ class ProfileSyncServiceHarness
const std::string& reason);
// A helper for implementing IsDataSynced() and IsFullySynced().
- bool IsDataSyncedImpl(const browser_sync::sessions::SyncSessionSnapshot*);
+ bool IsDataSyncedImpl(
+ const browser_sync::sessions::SyncSessionSnapshot& snapshot);
// Returns true if the sync client has no unsynced items.
bool IsDataSynced();
diff --git a/chrome/browser/sync/profile_sync_service_mock.h b/chrome/browser/sync/profile_sync_service_mock.h
index bcad588..68e9700 100644
--- a/chrome/browser/sync/profile_sync_service_mock.h
+++ b/chrome/browser/sync/profile_sync_service_mock.h
@@ -74,7 +74,7 @@ class ProfileSyncServiceMock : public ProfileSyncService {
MOCK_CONST_METHOD0(GetPreferredDataTypes, syncable::ModelTypeSet());
MOCK_CONST_METHOD0(GetRegisteredDataTypes, syncable::ModelTypeSet());
MOCK_CONST_METHOD0(GetLastSessionSnapshot,
- const browser_sync::sessions::SyncSessionSnapshot*());
+ browser_sync::sessions::SyncSessionSnapshot());
MOCK_METHOD0(QueryDetailedSyncStatus,
browser_sync::SyncBackendHost::Status());
diff --git a/chrome/browser/sync/retry_verifier.cc b/chrome/browser/sync/retry_verifier.cc
index 0fa3843..b7f395b 100644
--- a/chrome/browser/sync/retry_verifier.cc
+++ b/chrome/browser/sync/retry_verifier.cc
@@ -81,7 +81,7 @@ RetryVerifier::~RetryVerifier() {
void RetryVerifier::Initialize(
const browser_sync::sessions::SyncSessionSnapshot& snap) {
retry_count_ = 0;
- last_sync_time_ = snap.sync_start_time;
+ last_sync_time_ = snap.sync_start_time();
FillDelayTable(delay_table_, kMaxRetry);
done_ = false;
success_ = false;
@@ -91,9 +91,9 @@ void RetryVerifier::VerifyRetryInterval(
const browser_sync::sessions::SyncSessionSnapshot& snap) {
DCHECK(retry_count_ < kMaxRetry);
if (retry_count_ == 0) {
- if (snap.sync_start_time != last_sync_time_) {
+ if (snap.sync_start_time() != last_sync_time_) {
retry_count_++;
- last_sync_time_ = snap.sync_start_time;
+ last_sync_time_ = snap.sync_start_time();
}
success_ = true;
return;
@@ -101,10 +101,10 @@ void RetryVerifier::VerifyRetryInterval(
// Check if the sync start time has changed. If so indicates a new sync
// has taken place.
- if (snap.sync_start_time != last_sync_time_) {
- base::TimeDelta delta = snap.sync_start_time - last_sync_time_;
+ if (snap.sync_start_time() != last_sync_time_) {
+ base::TimeDelta delta = snap.sync_start_time() - last_sync_time_;
success_ = IsRetryOnTime(delay_table_,retry_count_ -1, delta);
- last_sync_time_ = snap.sync_start_time;
+ last_sync_time_ = snap.sync_start_time();
++retry_count_;
done_ = (retry_count_ >= kMaxRetry);
return;
diff --git a/chrome/browser/sync/retry_verifier.h b/chrome/browser/sync/retry_verifier.h
index 755dab9..95023e2 100644
--- a/chrome/browser/sync/retry_verifier.h
+++ b/chrome/browser/sync/retry_verifier.h
@@ -9,12 +9,11 @@
#include "base/time.h"
namespace browser_sync {
+
namespace sessions {
-struct SyncSessionSnapshot;
+class SyncSessionSnapshot;
} // namespace sessions
-} // namespace browser_sync
-namespace browser_sync {
// The minimum and maximum wait times for a retry. The actual retry would take
// place somewhere in this range. The algorithm that calculates the retry wait
// time uses rand functions.
@@ -47,5 +46,7 @@ class RetryVerifier {
bool done_;
DISALLOW_COPY_AND_ASSIGN(RetryVerifier);
};
+
} // namespace browser_sync
+
#endif // CHROME_BROWSER_SYNC_RETRY_VERIFIER_H_
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc
index a4ba0ae..9a8307a 100644
--- a/chrome/browser/sync/sync_ui_util.cc
+++ b/chrome/browser/sync/sync_ui_util.cc
@@ -520,7 +520,7 @@ void ConstructAboutInformation(ProfileSyncService* service,
service->QueryDetailedSyncStatus());
// This is a cache of the last snapshot of type SYNC_CYCLE_ENDED where
- // !snapshot->has_more_to_sync. In other words, it's the last in this
+ // !snapshot.has_more_to_sync(). In other words, it's the last in this
// series of sync cycles. The series ends only when we've done all we can
// to resolve conflicts and there is nothing left to commit, or an error
// occurs.
@@ -530,9 +530,10 @@ void ConstructAboutInformation(ProfileSyncService* service,
// the values from a single sync cycle.
//
// |snapshot| could be NULL if sync is not yet initialized.
- const browser_sync::sessions::SyncSessionSnapshot* snapshot =
+ const browser_sync::sessions::SyncSessionSnapshot& snapshot =
service->sync_initialized() ?
- service->GetLastSessionSnapshot() : NULL;
+ service->GetLastSessionSnapshot() :
+ browser_sync::sessions::SyncSessionSnapshot();
sync_ui_util::AddStringSyncDetails(sync_summary, "Summary",
service->QuerySyncStatusSummary());
@@ -574,10 +575,8 @@ void ConstructAboutInformation(ProfileSyncService* service,
// Network status indicators.
ListValue* network = AddSyncDetailsSection(details, "Network");
- if (snapshot) {
- sync_ui_util::AddBoolSyncDetail(network, "Throttled",
- snapshot->is_silenced);
- }
+ sync_ui_util::AddBoolSyncDetail(network, "Throttled",
+ snapshot.is_silenced());
sync_ui_util::AddBoolSyncDetail(network, "Notifications Enabled",
full_status.notifications_enabled);
@@ -608,22 +607,20 @@ void ConstructAboutInformation(ProfileSyncService* service,
ListValue* cycles = AddSyncDetailsSection(
details, "Status from Last Completed Session");
- if (snapshot) {
- sync_ui_util::AddStringSyncDetails(
- cycles, "Sync Source",
- browser_sync::GetUpdatesSourceString(
- snapshot->source.updates_source));
- sync_ui_util::AddStringSyncDetails(
- cycles, "Download Updates",
- GetSyncerErrorString(snapshot->errors.last_download_updates_result));
- sync_ui_util::AddStringSyncDetails(
- cycles, "Post Commit",
- GetSyncerErrorString(snapshot->errors.last_post_commit_result));
- sync_ui_util::AddStringSyncDetails(
- cycles, "Process Commit Response",
- GetSyncerErrorString(
- snapshot->errors.last_process_commit_response_result));
- }
+ sync_ui_util::AddStringSyncDetails(
+ cycles, "Sync Source",
+ browser_sync::GetUpdatesSourceString(
+ snapshot.source().updates_source));
+ sync_ui_util::AddStringSyncDetails(
+ cycles, "Download Updates",
+ GetSyncerErrorString(snapshot.errors().last_download_updates_result));
+ sync_ui_util::AddStringSyncDetails(
+ cycles, "Post Commit",
+ GetSyncerErrorString(snapshot.errors().last_post_commit_result));
+ sync_ui_util::AddStringSyncDetails(
+ cycles, "Process Commit Response",
+ GetSyncerErrorString(
+ snapshot.errors().last_process_commit_response_result));
// Strictly increasing counters.
ListValue* counters = AddSyncDetailsSection(details, "Running Totals");
@@ -697,24 +694,20 @@ void ConstructAboutInformation(ProfileSyncService* service,
ListValue* transient_session = AddSyncDetailsSection(
details, "Transient Counters (last cycle of last completed session)");
- if (snapshot) {
- sync_ui_util::AddIntSyncDetail(
- transient_session, "Updates Downloaded",
- snapshot->syncer_status.num_updates_downloaded_total);
- sync_ui_util::AddIntSyncDetail(
- transient_session, "Committed Count",
- snapshot->syncer_status.num_successful_commits);
- }
-
- if (snapshot) {
- // This counter is stale. The warnings related to the snapshot still
- // apply, see the comments near call to GetLastSessionSnapshot() above.
- // Also, because this is updated only following a complete sync cycle,
- // local changes affecting this count will not be displayed until the
- // syncer has attempted to commit those changes.
- sync_ui_util::AddIntSyncDetail(transient_session, "Entries",
- snapshot->num_entries);
- }
+ sync_ui_util::AddIntSyncDetail(
+ transient_session, "Updates Downloaded",
+ snapshot.syncer_status().num_updates_downloaded_total);
+ sync_ui_util::AddIntSyncDetail(
+ transient_session, "Committed Count",
+ snapshot.syncer_status().num_successful_commits);
+
+ // This counter is stale. The warnings related to the snapshot still
+ // apply, see the comments near call to GetLastSessionSnapshot() above.
+ // Also, because this is updated only following a complete sync cycle,
+ // local changes affecting this count will not be displayed until the
+ // syncer has attempted to commit those changes.
+ sync_ui_util::AddIntSyncDetail(transient_session, "Entries",
+ snapshot.num_entries());
// Now set the actionable errors.
if ((full_status.sync_protocol_error.error_type !=
diff --git a/chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc b/chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc
index f1ea473..ba4ead5 100644
--- a/chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc
+++ b/chrome/browser/sync/test/integration/two_client_bookmarks_sync_test.cc
@@ -1815,8 +1815,8 @@ IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
ASSERT_TRUE(IsEncrypted(0, syncable::BOOKMARKS));
ASSERT_TRUE(IsEncrypted(1, syncable::BOOKMARKS));
ASSERT_TRUE(GetClient(1)->service()->IsPassphraseRequired());
- ASSERT_GT(GetClient(1)->GetLastSessionSnapshot()->
- num_encryption_conflicts, 3); // The encrypted nodes.
+ ASSERT_GT(GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts(),
+ 3); // The encrypted nodes.
// Client 1 adds bookmarks between the first two and between the second two.
ASSERT_TRUE(AddURL(0, 1, IndexedURLTitle(3), GURL(IndexedURL(3))) != NULL);
@@ -1830,15 +1830,15 @@ IN_PROC_BROWSER_TEST_F(TwoClientBookmarksSyncTest,
ASSERT_TRUE(GetClient(1)->AwaitPassphraseAccepted());
ASSERT_TRUE(AwaitQuiescence());
EXPECT_TRUE(AllModelsMatch());
- ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
- num_encryption_conflicts);
+ ASSERT_EQ(0,
+ GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts());
// Ensure everything is syncing normally by appending a final bookmark.
ASSERT_TRUE(AddURL(1, 5, IndexedURLTitle(5), GURL(IndexedURL(5))) != NULL);
ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
EXPECT_TRUE(AllModelsMatch());
- ASSERT_EQ(0, GetClient(1)->GetLastSessionSnapshot()->
- num_encryption_conflicts);
+ ASSERT_EQ(0,
+ GetClient(1)->GetLastSessionSnapshot().num_encryption_conflicts());
}
// Deliberately racy rearranging of bookmarks to test that our conflict resolver
diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc
index 83e04c5..500a838 100644
--- a/chrome/browser/sync/test_profile_sync_service.cc
+++ b/chrome/browser/sync/test_profile_sync_service.cc
@@ -49,8 +49,8 @@ void SyncBackendHostForProfileSyncTest::
syncable::ModelTypeSet sync_ended;
if (!fail_initial_download_)
sync_ended = syncable::ModelTypeSet::All();
- std::string download_progress_markers[syncable::MODEL_TYPE_COUNT];
- HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot(
+ syncable::ModelTypePayloadMap download_progress_markers;
+ HandleSyncCycleCompletedOnFrontendLoop(SyncSessionSnapshot(
SyncerStatus(), ErrorCounters(), 0, false,
sync_ended, download_progress_markers, false, false, 0, 0, 0, 0, 0,
false, SyncSourceInfo(), false, 0, base::Time::Now(), false));
@@ -92,8 +92,8 @@ void SyncBackendHostForProfileSyncTest::StartConfiguration(
if (!fail_initial_download_)
sync_ended.Put(syncable::NIGORI);
- std::string download_progress_markers[syncable::MODEL_TYPE_COUNT];
- HandleSyncCycleCompletedOnFrontendLoop(new SyncSessionSnapshot(
+ syncable::ModelTypePayloadMap download_progress_markers;
+ HandleSyncCycleCompletedOnFrontendLoop(SyncSessionSnapshot(
SyncerStatus(), ErrorCounters(), 0, false,
sync_ended, download_progress_markers, false, false, 0, 0, 0, 0, 0,
false, SyncSourceInfo(), false, 0, base::Time::Now(), false));