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

Side by Side Diff: components/sync_wifi/wifi_credential_syncable_service.cc

Issue 2463463004: [Sync] Rename wifi_sync to sync_wifi. (Closed)
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/wifi_sync/wifi_credential_syncable_service.h" 5 #include "components/sync_wifi/wifi_credential_syncable_service.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "components/sync/model/sync_change.h" 13 #include "components/sync/model/sync_change.h"
14 #include "components/sync/model/sync_data.h" 14 #include "components/sync/model/sync_data.h"
15 #include "components/sync/model/sync_error.h" 15 #include "components/sync/model/sync_error.h"
16 #include "components/sync/model/sync_error_factory.h" 16 #include "components/sync/model/sync_error_factory.h"
17 #include "components/sync/model/sync_merge_result.h" 17 #include "components/sync/model/sync_merge_result.h"
18 #include "components/sync/protocol/sync.pb.h" 18 #include "components/sync/protocol/sync.pb.h"
19 #include "components/wifi_sync/wifi_credential.h" 19 #include "components/sync_wifi/wifi_credential.h"
20 #include "components/wifi_sync/wifi_security_class.h" 20 #include "components/sync_wifi/wifi_security_class.h"
21 21
22 namespace wifi_sync { 22 namespace sync_wifi {
23 23
24 namespace { 24 namespace {
25 25
26 struct RawCredentialData { 26 struct RawCredentialData {
27 std::vector<uint8_t> ssid; 27 std::vector<uint8_t> ssid;
28 WifiSecurityClass security_class; 28 WifiSecurityClass security_class;
29 std::string passphrase; 29 std::string passphrase;
30 }; 30 };
31 31
32 void BuildSpecifics(const WifiCredential& credential, 32 void BuildSpecifics(const WifiCredential& credential,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 const syncer::ModelType WifiCredentialSyncableService::kModelType = 107 const syncer::ModelType WifiCredentialSyncableService::kModelType =
108 syncer::WIFI_CREDENTIALS; 108 syncer::WIFI_CREDENTIALS;
109 109
110 WifiCredentialSyncableService::WifiCredentialSyncableService( 110 WifiCredentialSyncableService::WifiCredentialSyncableService(
111 std::unique_ptr<WifiConfigDelegate> network_config_delegate) 111 std::unique_ptr<WifiConfigDelegate> network_config_delegate)
112 : network_config_delegate_(std::move(network_config_delegate)) { 112 : network_config_delegate_(std::move(network_config_delegate)) {
113 DCHECK(network_config_delegate_); 113 DCHECK(network_config_delegate_);
114 } 114 }
115 115
116 WifiCredentialSyncableService::~WifiCredentialSyncableService() { 116 WifiCredentialSyncableService::~WifiCredentialSyncableService() {}
117 }
118 117
119 syncer::SyncMergeResult WifiCredentialSyncableService::MergeDataAndStartSyncing( 118 syncer::SyncMergeResult WifiCredentialSyncableService::MergeDataAndStartSyncing(
120 syncer::ModelType type, 119 syncer::ModelType type,
121 const syncer::SyncDataList& initial_sync_data, 120 const syncer::SyncDataList& initial_sync_data,
122 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, 121 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
123 std::unique_ptr<syncer::SyncErrorFactory> /* error_handler */) { 122 std::unique_ptr<syncer::SyncErrorFactory> /* error_handler */) {
124 DCHECK(!sync_processor_.get()); 123 DCHECK(!sync_processor_.get());
125 DCHECK(sync_processor.get()); 124 DCHECK(sync_processor.get());
126 DCHECK_EQ(kModelType, type); 125 DCHECK_EQ(kModelType, type);
127 126
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 bool WifiCredentialSyncableService::AddToSyncedNetworks( 197 bool WifiCredentialSyncableService::AddToSyncedNetworks(
199 const std::string& item_id, 198 const std::string& item_id,
200 const WifiCredential& credential) { 199 const WifiCredential& credential) {
201 if (!sync_processor_.get()) { 200 if (!sync_processor_.get()) {
202 // Callers must queue updates until MergeDataAndStartSyncing has 201 // Callers must queue updates until MergeDataAndStartSyncing has
203 // been called on this SyncableService. 202 // been called on this SyncableService.
204 LOG(WARNING) << "WifiCredentials syncable service is not started."; 203 LOG(WARNING) << "WifiCredentials syncable service is not started.";
205 return false; 204 return false;
206 } 205 }
207 206
208 const SsidAndSecurityClass network_id( 207 const SsidAndSecurityClass network_id(credential.ssid(),
209 credential.ssid(), credential.security_class()); 208 credential.security_class());
210 if (synced_networks_and_passphrases_.find(network_id) != 209 if (synced_networks_and_passphrases_.find(network_id) !=
211 synced_networks_and_passphrases_.end()) { 210 synced_networks_and_passphrases_.end()) {
212 // TODO(quiche): If passphrase has changed, submit this to sync as 211 // TODO(quiche): If passphrase has changed, submit this to sync as
213 // an ACTION_UPDATE. crbug.com/431436 212 // an ACTION_UPDATE. crbug.com/431436
214 return false; 213 return false;
215 } 214 }
216 215
217 syncer::SyncChangeList change_list; 216 syncer::SyncChangeList change_list;
218 syncer::SyncError sync_error; 217 syncer::SyncError sync_error;
219 sync_pb::EntitySpecifics wifi_credential_specifics; 218 sync_pb::EntitySpecifics wifi_credential_specifics;
220 BuildSpecifics(credential, &wifi_credential_specifics); 219 BuildSpecifics(credential, &wifi_credential_specifics);
221 change_list.push_back( 220 change_list.push_back(
222 syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_ADD, 221 syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_ADD,
223 syncer::SyncData::CreateLocalData( 222 syncer::SyncData::CreateLocalData(
224 item_id, item_id, wifi_credential_specifics))); 223 item_id, item_id, wifi_credential_specifics)));
225 sync_error = sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); 224 sync_error = sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
226 if (sync_error.IsSet()) { 225 if (sync_error.IsSet()) {
227 LOG(ERROR) << sync_error.ToString(); 226 LOG(ERROR) << sync_error.ToString();
228 return false; 227 return false;
229 } 228 }
230 229
231 synced_networks_and_passphrases_[network_id] = credential.passphrase(); 230 synced_networks_and_passphrases_[network_id] = credential.passphrase();
232 return true; 231 return true;
233 } 232 }
234 233
235 } // namespace wifi_sync 234 } // namespace sync_wifi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698