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

Unified Diff: components/wifi_sync/wifi_credential_syncable_service_impl.cc

Issue 1426393003: NOT FOR REVIEW Base URL: https://chromium.googlesource.com/chromium/src.git@submit-4.5-split-wcss
Patch Set: Created 5 years, 1 month 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/wifi_sync/wifi_credential_syncable_service_impl.cc
diff --git a/components/wifi_sync/wifi_credential_syncable_service_impl.cc b/components/wifi_sync/wifi_credential_syncable_service_impl.cc
index 311181e30159e831d0690a2cf17e65744d2a47fa..7e610f1b4f5cbec6fc165d732cfc0a8f63c849a3 100644
--- a/components/wifi_sync/wifi_credential_syncable_service_impl.cc
+++ b/components/wifi_sync/wifi_credential_syncable_service_impl.cc
@@ -8,6 +8,8 @@
#include <vector>
#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "components/wifi_sync/wifi_credential.h"
#include "components/wifi_sync/wifi_security_class.h"
#include "sync/api/sync_change.h"
@@ -100,15 +102,26 @@ bool ParseSyncData(const syncer::SyncData& sync_data,
return ParseSpecifics(sync_data.GetSpecifics(), raw_credential);
}
+std::string ComputeItemId(const WifiCredential credential) {
+ return base::StringPrintf(
+ "%s:%d",
+ base::HexEncode(credential.ssid().data(),
+ credential.ssid().size()).c_str(),
+ credential.security_class());
+}
+
} // namespace
const syncer::ModelType WifiCredentialSyncableServiceImpl::kModelType =
syncer::WIFI_CREDENTIALS;
WifiCredentialSyncableServiceImpl::WifiCredentialSyncableServiceImpl(
- scoped_ptr<WifiConfigDelegate> network_config_delegate)
- : network_config_delegate_(network_config_delegate.Pass()) {
+ scoped_ptr<WifiConfigDelegate> network_config_delegate,
+ scoped_ptr<WifiConfigObserver> network_config_observer)
+ : network_config_delegate_(network_config_delegate.Pass()),
+ network_config_observer_(network_config_observer.Pass()) {
DCHECK(network_config_delegate_);
+ DCHECK(network_config_observer_);
}
WifiCredentialSyncableServiceImpl::~WifiCredentialSyncableServiceImpl() {
@@ -126,14 +139,15 @@ syncer::SyncMergeResult WifiCredentialSyncableServiceImpl::MergeDataAndStartSync
sync_processor_ = sync_processor.Pass();
// TODO(quiche): Update local WiFi configuration from |initial_sync_data|.
- // TODO(quiche): Notify upper layers that sync is ready.
NOTIMPLEMENTED();
+ network_config_observer_->StartSyncing(base::AsWeakPtr(this));
return syncer::SyncMergeResult(type);
}
void WifiCredentialSyncableServiceImpl::StopSyncing(syncer::ModelType type) {
DCHECK_EQ(kModelType, type);
+ network_config_observer_->StopSyncing();
sync_processor_.reset();
}
@@ -194,7 +208,6 @@ syncer::SyncError WifiCredentialSyncableServiceImpl::ProcessSyncChanges(
}
bool WifiCredentialSyncableServiceImpl::AddToSyncedNetworks(
- const std::string& item_id,
const WifiCredential& credential) {
if (!sync_processor_.get()) {
// Callers must queue updates until MergeDataAndStartSyncing has
@@ -215,6 +228,7 @@ bool WifiCredentialSyncableServiceImpl::AddToSyncedNetworks(
syncer::SyncChangeList change_list;
syncer::SyncError sync_error;
sync_pb::EntitySpecifics wifi_credential_specifics;
+ std::string item_id(ComputeItemId(credential));
BuildSpecifics(credential, &wifi_credential_specifics);
change_list.push_back(
syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_ADD,

Powered by Google App Engine
This is Rietveld 408576698