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

Unified Diff: components/sync_driver/local_device_info_provider_impl.cc

Issue 1951703002: [Sync] Clear LocalDeviceInfoProvider cache on sync DB destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move NonThreadSafe to LocalDeviceInfoProviderImpl. Created 4 years, 7 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
Index: components/sync_driver/local_device_info_provider_impl.cc
diff --git a/components/sync_driver/local_device_info_provider_impl.cc b/components/sync_driver/local_device_info_provider_impl.cc
index 37ef98fb54208f3eca66a378321ff006db669b85..82be36835bad2718f12246b7433d770d51da9015 100644
--- a/components/sync_driver/local_device_info_provider_impl.cc
+++ b/components/sync_driver/local_device_info_provider_impl.cc
@@ -40,16 +40,20 @@ LocalDeviceInfoProviderImpl::LocalDeviceInfoProviderImpl(
: channel_(channel),
version_(version),
is_tablet_(is_tablet),
- weak_factory_(this) {}
+ weak_factory_(this) {
+ DCHECK(CalledOnValidThread());
+}
LocalDeviceInfoProviderImpl::~LocalDeviceInfoProviderImpl() {}
const sync_driver::DeviceInfo* LocalDeviceInfoProviderImpl::GetLocalDeviceInfo()
const {
+ DCHECK(CalledOnValidThread());
return local_device_info_.get();
}
std::string LocalDeviceInfoProviderImpl::GetSyncUserAgent() const {
+ DCHECK(CalledOnValidThread());
#if defined(OS_CHROMEOS)
return MakeUserAgentForSync("CROS ", channel_);
#elif defined(OS_ANDROID)
@@ -70,12 +74,14 @@ std::string LocalDeviceInfoProviderImpl::GetSyncUserAgent() const {
}
std::string LocalDeviceInfoProviderImpl::GetLocalSyncCacheGUID() const {
+ DCHECK(CalledOnValidThread());
return cache_guid_;
}
std::unique_ptr<sync_driver::LocalDeviceInfoProvider::Subscription>
LocalDeviceInfoProviderImpl::RegisterOnInitializedCallback(
const base::Closure& callback) {
+ DCHECK(CalledOnValidThread());
DCHECK(!local_device_info_.get());
return callback_list_.Add(callback);
}
@@ -84,6 +90,7 @@ void LocalDeviceInfoProviderImpl::Initialize(
const std::string& cache_guid,
const std::string& signin_scoped_device_id,
const scoped_refptr<base::TaskRunner>& blocking_task_runner) {
+ DCHECK(CalledOnValidThread());
DCHECK(!cache_guid.empty());
cache_guid_ = cache_guid;
@@ -98,6 +105,12 @@ void LocalDeviceInfoProviderImpl::InitializeContinuation(
const std::string& guid,
const std::string& signin_scoped_device_id,
const std::string& session_name) {
+ DCHECK(CalledOnValidThread());
+ if (guid != cache_guid_) {
+ // Clear() happened before this callback; abort.
+ return;
+ }
+
local_device_info_.reset(new sync_driver::DeviceInfo(
guid, session_name, version_, GetSyncUserAgent(),
GetLocalDeviceType(is_tablet_), signin_scoped_device_id));
@@ -106,4 +119,10 @@ void LocalDeviceInfoProviderImpl::InitializeContinuation(
callback_list_.Notify();
}
+void LocalDeviceInfoProviderImpl::Clear() {
+ DCHECK(CalledOnValidThread());
+ cache_guid_ = "";
+ local_device_info_.reset();
+}
+
} // namespace browser_sync
« no previous file with comments | « components/sync_driver/local_device_info_provider_impl.h ('k') | components/sync_driver/local_device_info_provider_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698