Commit 1693af2c authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

Revert "[DeviceSync v2] Add CryptAuthInstanceIDProvider class"

This reverts commit 55465550.

Reason for revert: This class is no longer needed. It was initially created to fetch Instance ID tokens for multiple services, namely v2 Enrollment and DeviceSync. However, CryptAuth decided it will only use one Instance ID token corresponding to CryptAuth v2 Enrollment. The Instance ID and token are already fetched in the ClientAppMetadataProvider. In the future, Instance ID handling might be moved to the CryptAuthGCMManager.

Original change's description:
> [DeviceSync v2] Add CryptAuthInstanceIDProvider class
> 
> Add an abstract class (and a fake implementation) for providing an
> Instance ID for use with CryptAuth v2, and also for providing Instance
> ID tokens for each CryptAuth v2 project: Enrollment and DeviceSync.
> 
> The implementation will follow in another CL.
> 
> Bug: 951969, 990430
> Change-Id: I6fd3280bf5a12114a92059a8a84bd0d1749c627b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1737951
> Commit-Queue: Josh Nohle <nohle@chromium.org>
> Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#684479}

TBR=khorimoto@chromium.org,nohle@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 951969, 990430
Change-Id: Ic05c8033bd092c995050f76b1b5434507c843617
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866628Reviewed-by: default avatarJosh Nohle <nohle@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709141}
parent ca9d3df2
......@@ -6,8 +6,6 @@ source_set("cpp") {
sources = [
"client_app_metadata_provider.h",
"cryptauth_device_id_provider.h",
"cryptauth_instance_id_provider.cc",
"cryptauth_instance_id_provider.h",
"device_sync_client.cc",
"device_sync_client.h",
"device_sync_client_impl.cc",
......@@ -35,8 +33,6 @@ static_library("test_support") {
sources = [
"fake_client_app_metadata_provider.cc",
"fake_client_app_metadata_provider.h",
"fake_cryptauth_instance_id_provider.cc",
"fake_cryptauth_instance_id_provider.h",
"fake_device_sync_client.cc",
"fake_device_sync_client.h",
"fake_gcm_device_info_provider.cc",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/device_sync/public/cpp/cryptauth_instance_id_provider.h"
namespace chromeos {
namespace device_sync {
CryptAuthInstanceIdProvider::CryptAuthInstanceIdProvider() = default;
CryptAuthInstanceIdProvider::~CryptAuthInstanceIdProvider() = default;
std::ostream& operator<<(
std::ostream& stream,
const CryptAuthInstanceIdProvider::CryptAuthService cryptauth_service) {
switch (cryptauth_service) {
case CryptAuthInstanceIdProvider::CryptAuthService::kEnrollmentV2:
stream << "[CryptAuth service: Enrollment v2]";
break;
case CryptAuthInstanceIdProvider::CryptAuthService::kDeviceSyncV2:
stream << "[CryptAuth service: DeviceSync v2]";
break;
}
return stream;
}
} // namespace device_sync
} // namespace chromeos
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_CPP_CRYPTAUTH_INSTANCE_ID_PROVIDER_H_
#define CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_CPP_CRYPTAUTH_INSTANCE_ID_PROVIDER_H_
#include <ostream>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/optional.h"
namespace chromeos {
namespace device_sync {
// Provides the user with a unique and immutable GCM Instance ID for use across
// CryptAuth v2 services. Provides unique and immutable Instance ID tokens for
// each CryptAuth v2 service: Enrollment and DeviceSync.
class CryptAuthInstanceIdProvider {
public:
enum class CryptAuthService { kEnrollmentV2, kDeviceSyncV2 };
CryptAuthInstanceIdProvider();
virtual ~CryptAuthInstanceIdProvider();
using GetInstanceIdCallback =
base::OnceCallback<void(const base::Optional<std::string>&)>;
using GetInstanceIdTokenCallback =
base::OnceCallback<void(const base::Optional<std::string>&)>;
// Provides the user with a unique and immutable GCM Instance ID for use
// across CryptAuth v2 services; if the operation fails, null is passed to the
// callback.
virtual void GetInstanceId(GetInstanceIdCallback callback) = 0;
// Provides the user with a unique and immutable GCM Instance ID token
// corresponding to the CryptAuth service, |cryptauth_service|; if the
// operation fails, null is passed to the callback.
//
// By retrieving a token for a given service, we implicitly authorize that
// service to send us GCM push notifications; the token is the identifier of
// that registration.
virtual void GetInstanceIdToken(CryptAuthService cryptauth_service,
GetInstanceIdTokenCallback callback) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(CryptAuthInstanceIdProvider);
};
std::ostream& operator<<(
std::ostream& stream,
const CryptAuthInstanceIdProvider::CryptAuthService cryptauth_service);
} // namespace device_sync
} // namespace chromeos
#endif // CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_CPP_CRYPTAUTH_INSTANCE_ID_PROVIDER_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/device_sync/public/cpp/fake_cryptauth_instance_id_provider.h"
namespace chromeos {
namespace device_sync {
FakeCryptAuthInstanceIdProvider::FakeCryptAuthInstanceIdProvider() = default;
FakeCryptAuthInstanceIdProvider::~FakeCryptAuthInstanceIdProvider() = default;
void FakeCryptAuthInstanceIdProvider::GetInstanceId(
GetInstanceIdCallback callback) {
instance_id_callbacks_.push_back(std::move(callback));
}
void FakeCryptAuthInstanceIdProvider::GetInstanceIdToken(
CryptAuthService cryptauth_service,
GetInstanceIdTokenCallback callback) {
instance_id_token_callbacks_[cryptauth_service].push_back(
std::move(callback));
}
} // namespace device_sync
} // namespace chromeos
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_CPP_FAKE_CRYPTAUTH_INSTANCE_ID_PROVIDER_H_
#define CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_CPP_FAKE_CRYPTAUTH_INSTANCE_ID_PROVIDER_H_
#include <vector>
#include "base/callback.h"
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "chromeos/services/device_sync/public/cpp/cryptauth_instance_id_provider.h"
namespace chromeos {
namespace device_sync {
// Implementation of CryptAuthInstanceIdProvider for use in tests.
class FakeCryptAuthInstanceIdProvider : public CryptAuthInstanceIdProvider {
public:
FakeCryptAuthInstanceIdProvider();
~FakeCryptAuthInstanceIdProvider() override;
// CryptAuthInstanceIdProvider:
void GetInstanceId(GetInstanceIdCallback callback) override;
void GetInstanceIdToken(CryptAuthService cryptauth_service,
GetInstanceIdTokenCallback callback) override;
// Returns the array of callbacks sent to GetInstanceId(), ordered from first
// call to last call. Because this array is returned by reference, the client
// can invoke the callback of the i-th call using the following:
//
// std::move(instance_id_callbacks()[i]).Run(...)
std::vector<GetInstanceIdCallback>& instance_id_callbacks() {
return instance_id_callbacks_;
}
// Returns the array of callbacks sent to GetInstanceIdToken() for the
// given |cryptauth_service|, ordered from first call to last call. Because
// this array is returned by reference, the client can invoke the callback of
// the i-th call using the following:
//
// std::move(instance_id_token_callbacks(<CryptAuthService>)[i]).Run(...)
std::vector<GetInstanceIdTokenCallback>& instance_id_token_callbacks(
const CryptAuthService& cryptauth_service) {
return instance_id_token_callbacks_[cryptauth_service];
}
private:
std::vector<GetInstanceIdCallback> instance_id_callbacks_;
base::flat_map<CryptAuthService, std::vector<GetInstanceIdTokenCallback>>
instance_id_token_callbacks_;
DISALLOW_COPY_AND_ASSIGN(FakeCryptAuthInstanceIdProvider);
};
} // namespace device_sync
} // namespace chromeos
#endif // CHROMEOS_SERVICES_DEVICE_SYNC_PUBLIC_CPP_FAKE_CRYPTAUTH_INSTANCE_ID_PROVIDER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment