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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 invocation_reason = INVOCATION_REASON_INITIALIZATION; | 536 invocation_reason = INVOCATION_REASON_INITIALIZATION; |
536 } else if (IsRecoveringFromFailure()) { | 537 } else if (IsRecoveringFromFailure()) { |
537 invocation_reason = INVOCATION_REASON_FAILURE_RECOVERY; | 538 invocation_reason = INVOCATION_REASON_FAILURE_RECOVERY; |
538 } else { | 539 } else { |
539 invocation_reason = INVOCATION_REASON_PERIODIC; | 540 invocation_reason = INVOCATION_REASON_PERIODIC; |
540 } | 541 } |
541 | 542 |
542 GetMyDevicesRequest request; | 543 GetMyDevicesRequest request; |
543 request.set_invocation_reason(invocation_reason); | 544 request.set_invocation_reason(invocation_reason); |
544 request.set_allow_stale_read(is_sync_speculative); | 545 request.set_allow_stale_read(is_sync_speculative); |
| 546 net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation = |
| 547 net::DefinePartialNetworkTrafficAnnotation("cryptauth_get_my_devices", |
| 548 "oauth2_api_call_flow", R"( |
| 549 semantics { |
| 550 sender: "CryptAuth Device Manager" |
| 551 description: |
| 552 "Gets a list of the devices registered (for the same user) on " |
| 553 "CryptAuth." |
| 554 trigger: |
| 555 "Once every day, or by API request. Periodic calls happen because " |
| 556 "devides that do not re-enrolled for more than X days (currently 45) " |
| 557 "are automatically removed from the server." |
| 558 data: "OAuth 2.0 token." |
| 559 destination: GOOGLE_OWNED_SERVICE |
| 560 } |
| 561 policy { |
| 562 setting: |
| 563 "This feature cannot be disabled in settings. However, this request " |
| 564 "is made only for signed-in users." |
| 565 chrome_policy { |
| 566 SigninAllowed { |
| 567 SigninAllowed: false |
| 568 } |
| 569 } |
| 570 })"); |
545 cryptauth_client_->GetMyDevices( | 571 cryptauth_client_->GetMyDevices( |
546 request, base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, | 572 request, |
547 weak_ptr_factory_.GetWeakPtr()), | 573 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesSuccess, |
| 574 weak_ptr_factory_.GetWeakPtr()), |
548 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, | 575 base::Bind(&CryptAuthDeviceManager::OnGetMyDevicesFailure, |
549 weak_ptr_factory_.GetWeakPtr())); | 576 weak_ptr_factory_.GetWeakPtr()), |
| 577 partial_traffic_annotation); |
550 } | 578 } |
551 | 579 |
552 } // namespace cryptauth | 580 } // namespace cryptauth |
OLD | NEW |