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

Side by Side Diff: components/cryptauth/cryptauth_device_manager.cc

Issue 2928733004: CryptAuth: Improve logging around device syncing to display a human-readable device name. (Closed)
Patch Set: Fix typo. Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/cryptauth/cryptauth_device_manager.h" 5 #include "components/cryptauth/cryptauth_device_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdexcept> 8 #include <stdexcept>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 tether_hosts.push_back(device); 412 tether_hosts.push_back(device);
413 } 413 }
414 } 414 }
415 return tether_hosts; 415 return tether_hosts;
416 } 416 }
417 417
418 void CryptAuthDeviceManager::OnGetMyDevicesSuccess( 418 void CryptAuthDeviceManager::OnGetMyDevicesSuccess(
419 const GetMyDevicesResponse& response) { 419 const GetMyDevicesResponse& response) {
420 // Update the synced devices stored in the user's prefs. 420 // Update the synced devices stored in the user's prefs.
421 std::unique_ptr<base::ListValue> devices_as_list(new base::ListValue()); 421 std::unique_ptr<base::ListValue> devices_as_list(new base::ListValue());
422
423 if (!response.devices().empty())
424 PA_LOG(INFO) << "Devices were successfully synced.";
425
422 for (const auto& device : response.devices()) { 426 for (const auto& device : response.devices()) {
423 devices_as_list->Append(UnlockKeyToDictionary(device)); 427 std::unique_ptr<base::DictionaryValue> device_dictionary =
428 UnlockKeyToDictionary(device);
429
430 const std::string& device_name = device.has_friendly_device_name()
431 ? device.friendly_device_name()
432 : "[unknown]";
433 PA_LOG(INFO) << "Synced device '" << device_name
434 << "': " << *device_dictionary;
435
436 devices_as_list->Append(std::move(device_dictionary));
424 } 437 }
425 PA_LOG(INFO) << "Devices Synced:\n" << *devices_as_list;
426 438
427 bool unlock_keys_changed = !devices_as_list->Equals( 439 bool unlock_keys_changed = !devices_as_list->Equals(
428 pref_service_->GetList(prefs::kCryptAuthDeviceSyncUnlockKeys)); 440 pref_service_->GetList(prefs::kCryptAuthDeviceSyncUnlockKeys));
429 { 441 {
430 ListPrefUpdate update(pref_service_, prefs::kCryptAuthDeviceSyncUnlockKeys); 442 ListPrefUpdate update(pref_service_, prefs::kCryptAuthDeviceSyncUnlockKeys);
431 update.Get()->Swap(devices_as_list.get()); 443 update.Get()->Swap(devices_as_list.get());
432 } 444 }
433 UpdateUnlockKeysFromPrefs(); 445 UpdateUnlockKeysFromPrefs();
434 446
435 // Reset metadata used for scheduling syncing. 447 // Reset metadata used for scheduling syncing.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 request.set_invocation_reason(invocation_reason); 542 request.set_invocation_reason(invocation_reason);
531 request.set_allow_stale_read(is_sync_speculative); 543 request.set_allow_stale_read(is_sync_speculative);
532 cryptauth_client_->GetMyDevices( 544 cryptauth_client_->GetMyDevices(
533 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, 545 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess,
534 weak_ptr_factory_.GetWeakPtr()), 546 weak_ptr_factory_.GetWeakPtr()),
535 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, 547 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure,
536 weak_ptr_factory_.GetWeakPtr())); 548 weak_ptr_factory_.GetWeakPtr()));
537 } 549 }
538 550
539 } // namespace cryptauth 551 } // namespace cryptauth
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698