Commit a4b08fd2 authored by Maksim Moskvitin's avatar Maksim Moskvitin Committed by Commit Bot

[TrustedVault] Plumb network dependency to Connection

This CL plumbs PendingSharedURLLoaderFactory to
TrustedVaultConnectionImpl, and address noisy NOTIMPLEMENTED in
TrustedVaultConnectionImpl.

Bug: 1113598
Change-Id: I3287ed4ac1bb4599d1227e9cb90563ce0d650d86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2435227
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813738}
parent 0d6263e5
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
#include "components/sync_user_events/user_event_service.h" #include "components/sync_user_events/user_event_service.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/api/storage/backend_task_runner.h" #include "extensions/browser/api/storage/backend_task_runner.h"
#include "extensions/buildflags/buildflags.h" #include "extensions/buildflags/buildflags.h"
...@@ -230,7 +231,9 @@ ChromeSyncClient::ChromeSyncClient(Profile* profile) : profile_(profile) { ...@@ -230,7 +231,9 @@ ChromeSyncClient::ChromeSyncClient(Profile* profile) : profile_(profile) {
trusted_vault_client_ = trusted_vault_client_ =
std::make_unique<syncer::StandaloneTrustedVaultClient>( std::make_unique<syncer::StandaloneTrustedVaultClient>(
profile_->GetPath().Append(kTrustedVaultFilename), profile_->GetPath().Append(kTrustedVaultFilename),
IdentityManagerFactory::GetForProfile(profile_)); IdentityManagerFactory::GetForProfile(profile_),
content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess());
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
} }
......
...@@ -134,7 +134,8 @@ class BackendDelegate : public StandaloneTrustedVaultBackend::Delegate { ...@@ -134,7 +134,8 @@ class BackendDelegate : public StandaloneTrustedVaultBackend::Delegate {
StandaloneTrustedVaultClient::StandaloneTrustedVaultClient( StandaloneTrustedVaultClient::StandaloneTrustedVaultClient(
const base::FilePath& file_path, const base::FilePath& file_path,
signin::IdentityManager* identity_manager) signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
: backend_task_runner_( : backend_task_runner_(
base::ThreadPool::CreateSequencedTaskRunner(kBackendTaskTraits)), base::ThreadPool::CreateSequencedTaskRunner(kBackendTaskTraits)),
access_token_fetcher_frontend_(identity_manager) { access_token_fetcher_frontend_(identity_manager) {
...@@ -142,10 +143,6 @@ StandaloneTrustedVaultClient::StandaloneTrustedVaultClient( ...@@ -142,10 +143,6 @@ StandaloneTrustedVaultClient::StandaloneTrustedVaultClient(
switches::kSyncSupportTrustedVaultPassphrase)) { switches::kSyncSupportTrustedVaultPassphrase)) {
return; return;
} }
// TODO(crbug.com/1113598): populate URLLoaderFactory into
// TrustedVaultConnectionImpl ctor.
// TODO(crbug.com/1102340): allow setting custom TrustedVaultConnection for
// testing.
backend_ = base::MakeRefCounted<StandaloneTrustedVaultBackend>( backend_ = base::MakeRefCounted<StandaloneTrustedVaultBackend>(
file_path, file_path,
std::make_unique< std::make_unique<
...@@ -153,7 +150,7 @@ StandaloneTrustedVaultClient::StandaloneTrustedVaultClient( ...@@ -153,7 +150,7 @@ StandaloneTrustedVaultClient::StandaloneTrustedVaultClient(
&StandaloneTrustedVaultClient::NotifyRecoverabilityDegradedChanged, &StandaloneTrustedVaultClient::NotifyRecoverabilityDegradedChanged,
weak_ptr_factory_.GetWeakPtr()))), weak_ptr_factory_.GetWeakPtr()))),
std::make_unique<TrustedVaultConnectionImpl>( std::make_unique<TrustedVaultConnectionImpl>(
/*url_loader_factory=*/nullptr, url_loader_factory->Clone(),
std::make_unique<TrustedVaultAccessTokenFetcherImpl>( std::make_unique<TrustedVaultAccessTokenFetcherImpl>(
access_token_fetcher_frontend_.GetWeakPtr()))); access_token_fetcher_frontend_.GetWeakPtr())));
backend_task_runner_->PostTask( backend_task_runner_->PostTask(
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
struct CoreAccountInfo; struct CoreAccountInfo;
namespace network {
class SharedURLLoaderFactory;
} // namespace network
namespace syncer { namespace syncer {
class StandaloneTrustedVaultBackend; class StandaloneTrustedVaultBackend;
...@@ -33,8 +37,12 @@ class StandaloneTrustedVaultBackend; ...@@ -33,8 +37,12 @@ class StandaloneTrustedVaultBackend;
class StandaloneTrustedVaultClient : public TrustedVaultClient { class StandaloneTrustedVaultClient : public TrustedVaultClient {
public: public:
// |identity_manager| must not be null and must outlive this object. // |identity_manager| must not be null and must outlive this object.
StandaloneTrustedVaultClient(const base::FilePath& file_path, // |url_loader_factory| must not be null.
signin::IdentityManager* identity_manager); StandaloneTrustedVaultClient(
const base::FilePath& file_path,
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
StandaloneTrustedVaultClient(const StandaloneTrustedVaultClient& other) = StandaloneTrustedVaultClient(const StandaloneTrustedVaultClient& other) =
delete; delete;
StandaloneTrustedVaultClient& operator=( StandaloneTrustedVaultClient& operator=(
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "components/sync/trusted_vault/trusted_vault_connection_impl.h" #include "components/sync/trusted_vault/trusted_vault_connection_impl.h"
#include <utility>
#include "components/sync/trusted_vault/securebox.h" #include "components/sync/trusted_vault/securebox.h"
#include "components/sync/trusted_vault/trusted_vault_access_token_fetcher.h" #include "components/sync/trusted_vault/trusted_vault_access_token_fetcher.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
...@@ -12,9 +14,11 @@ namespace syncer { ...@@ -12,9 +14,11 @@ namespace syncer {
TrustedVaultConnectionImpl::TrustedVaultConnectionImpl( TrustedVaultConnectionImpl::TrustedVaultConnectionImpl(
std::unique_ptr<network::PendingSharedURLLoaderFactory> url_loader_factory, std::unique_ptr<network::PendingSharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<TrustedVaultAccessTokenFetcher> access_token_fetcher) { std::unique_ptr<TrustedVaultAccessTokenFetcher> access_token_fetcher)
NOTIMPLEMENTED(); : pending_url_loader_factory_(std::move(url_loader_factory)),
} access_token_fetcher_(std::move(access_token_fetcher)) {}
TrustedVaultConnectionImpl::~TrustedVaultConnectionImpl() = default;
void TrustedVaultConnectionImpl::RegisterAuthenticationFactor( void TrustedVaultConnectionImpl::RegisterAuthenticationFactor(
const CoreAccountInfo& account_info, const CoreAccountInfo& account_info,
......
...@@ -24,13 +24,13 @@ class TrustedVaultConnectionImpl : public TrustedVaultConnection { ...@@ -24,13 +24,13 @@ class TrustedVaultConnectionImpl : public TrustedVaultConnection {
public: public:
TrustedVaultConnectionImpl( TrustedVaultConnectionImpl(
std::unique_ptr<network::PendingSharedURLLoaderFactory> std::unique_ptr<network::PendingSharedURLLoaderFactory>
url_loader_factory, pending_url_loader_factory,
std::unique_ptr<TrustedVaultAccessTokenFetcher> access_token_fetcher); std::unique_ptr<TrustedVaultAccessTokenFetcher> access_token_fetcher);
TrustedVaultConnectionImpl(const TrustedVaultConnectionImpl& other) = delete; TrustedVaultConnectionImpl(const TrustedVaultConnectionImpl& other) = delete;
TrustedVaultConnectionImpl& operator=( TrustedVaultConnectionImpl& operator=(
const TrustedVaultConnectionImpl& other) = delete; const TrustedVaultConnectionImpl& other) = delete;
~TrustedVaultConnectionImpl() override = default; ~TrustedVaultConnectionImpl() override;
void RegisterAuthenticationFactor( void RegisterAuthenticationFactor(
const CoreAccountInfo& account_info, const CoreAccountInfo& account_info,
...@@ -44,6 +44,11 @@ class TrustedVaultConnectionImpl : public TrustedVaultConnection { ...@@ -44,6 +44,11 @@ class TrustedVaultConnectionImpl : public TrustedVaultConnection {
int last_trusted_vault_key_version, int last_trusted_vault_key_version,
std::unique_ptr<SecureBoxKeyPair> device_key_pair, std::unique_ptr<SecureBoxKeyPair> device_key_pair,
DownloadKeysCallback callback) override; DownloadKeysCallback callback) override;
private:
const std::unique_ptr<network::PendingSharedURLLoaderFactory>
pending_url_loader_factory_;
const std::unique_ptr<TrustedVaultAccessTokenFetcher> access_token_fetcher_;
}; };
} // namespace syncer } // namespace syncer
......
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