Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 #include "base/base64url.h" | 11 #include "base/base64url.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "components/cryptauth/cryptauth_client.h" | 14 #include "components/cryptauth/cryptauth_client.h" |
| 15 #include "components/cryptauth/pref_names.h" | 15 #include "components/cryptauth/pref_names.h" |
| 16 #include "components/cryptauth/sync_scheduler_impl.h" | 16 #include "components/cryptauth/sync_scheduler_impl.h" |
| 17 #include "components/prefs/pref_registry_simple.h" | 17 #include "components/prefs/pref_registry_simple.h" |
| 18 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
| 19 #include "components/prefs/scoped_user_pref_update.h" | 19 #include "components/prefs/scoped_user_pref_update.h" |
| 20 #include "components/proximity_auth/logging/logging.h" | 20 #include "components/proximity_auth/logging/logging.h" |
| 21 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 21 | 22 |
| 22 namespace cryptauth { | 23 namespace cryptauth { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // The normal period between successful syncs, in hours. | 27 // The normal period between successful syncs, in hours. |
| 27 const int kRefreshPeriodHours = 24; | 28 const int kRefreshPeriodHours = 24; |
| 28 | 29 |
| 29 // A more aggressive period between sync attempts to recover when the last | 30 // A more aggressive period between sync attempts to recover when the last |
| 30 // sync attempt fails, in minutes. This is a base time that increases for each | 31 // sync attempt fails, in minutes. This is a base time that increases for each |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 invocation_reason = INVOCATION_REASON_INITIALIZATION; | 535 invocation_reason = INVOCATION_REASON_INITIALIZATION; |
| 535 } else if (IsRecoveringFromFailure()) { | 536 } else if (IsRecoveringFromFailure()) { |
| 536 invocation_reason = INVOCATION_REASON_FAILURE_RECOVERY; | 537 invocation_reason = INVOCATION_REASON_FAILURE_RECOVERY; |
| 537 } else { | 538 } else { |
| 538 invocation_reason = INVOCATION_REASON_PERIODIC; | 539 invocation_reason = INVOCATION_REASON_PERIODIC; |
| 539 } | 540 } |
| 540 | 541 |
| 541 GetMyDevicesRequest request; | 542 GetMyDevicesRequest request; |
| 542 request.set_invocation_reason(invocation_reason); | 543 request.set_invocation_reason(invocation_reason); |
| 543 request.set_allow_stale_read(is_sync_speculative); | 544 request.set_allow_stale_read(is_sync_speculative); |
| 545 net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation = | |
| 546 net::DefinePartialNetworkTrafficAnnotation("cryptauth_get_my_devices", | |
| 547 "oauth2_api_call_flow", R"( | |
| 548 semantics { | |
| 549 sender: "CryptAuth Device Manager" | |
| 550 description: | |
| 551 "Gets a list of the devices registered (for the same user) on " | |
|
msramek
2017/06/28 08:40:55
Ditto here.
Ramin Halavati
2017/06/30 11:51:36
Acknowledged.
| |
| 552 "CryptAuth." | |
| 553 trigger: "Once every day, or by API request." | |
| 554 data: "OAuth 2.0 token." | |
| 555 destination: GOOGLE_OWNED_SERVICE | |
| 556 } | |
| 557 policy { | |
| 558 setting: "This feature cannot be disabled in settings." | |
|
msramek
2017/06/28 08:40:55
nit: Consistency. The previous annotation tended t
Ramin Halavati
2017/06/28 09:21:29
Done.
| |
| 559 chrome_policy { | |
| 560 SigninAllowed { | |
| 561 SigninAllowed: false | |
| 562 } | |
| 563 } | |
| 564 })"); | |
| 544 cryptauth_client_->GetMyDevices( | 565 cryptauth_client_->GetMyDevices( |
| 545 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, | 566 request, |
| 546 weak_ptr_factory_.GetWeakPtr()), | 567 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, |
| 568 weak_ptr_factory_.GetWeakPtr()), | |
| 547 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, | 569 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, |
| 548 weak_ptr_factory_.GetWeakPtr())); | 570 weak_ptr_factory_.GetWeakPtr()), |
| 571 partial_traffic_annotation); | |
| 549 } | 572 } |
| 550 | 573 |
| 551 } // namespace cryptauth | 574 } // namespace cryptauth |
| OLD | NEW |