[remoting] Migrate directory services to Protobuf over HTTP
This CL introduces a DirectoryServiceClient for communicating with the
remoting directory service via Protobuf over HTTP, and makes existing
gRPC based directory client users (i.e. Android and iOS clients, and the
start host command) use the new unified client.
Bug: 1103416
Change-Id: Ib3062f0aec3012774928adc81b4786a89f79146d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2311696
Commit-Queue: Yuwei Huang <[email protected]>
Reviewed-by: Nicolas Ouellet-Payeur <[email protected]>
Reviewed-by: Joe Downing <[email protected]>
Cr-Commit-Position: refs/heads/master@{#792081}
diff --git a/remoting/client/chromoting_client_runtime.cc b/remoting/client/chromoting_client_runtime.cc
index 0393c81..9ead2b543 100644
--- a/remoting/client/chromoting_client_runtime.cc
+++ b/remoting/client/chromoting_client_runtime.cc
@@ -15,6 +15,7 @@
#include "build/build_config.h"
#include "mojo/core/embedder/embedder.h"
#include "remoting/base/chromium_url_request.h"
+#include "remoting/base/directory_service_client.h"
#include "remoting/base/oauth_token_getter_proxy.h"
#include "remoting/base/telemetry_log_writer.h"
#include "remoting/base/url_request_context_getter.h"
@@ -89,6 +90,28 @@
delegate_->oauth_token_getter(), ui_task_runner());
}
+base::SequenceBound<DirectoryServiceClient>
+ChromotingClientRuntime::CreateDirectoryServiceClient() {
+ // A DirectoryServiceClient subclass that calls url_loader_factory() in its
+ // constructor, as we can't call it on a non-network thread then pass it via
+ // base::SequenceBound.
+ class ClientDirectoryServiceClient : public DirectoryServiceClient {
+ public:
+ ClientDirectoryServiceClient(ChromotingClientRuntime* runtime,
+ std::unique_ptr<OAuthTokenGetter> token_getter)
+ : DirectoryServiceClient(token_getter.get(),
+ runtime->url_loader_factory()),
+ token_getter_(std::move(token_getter)) {}
+ ~ClientDirectoryServiceClient() override = default;
+
+ private:
+ std::unique_ptr<OAuthTokenGetter> token_getter_;
+ };
+
+ return base::SequenceBound<ClientDirectoryServiceClient>(
+ network_task_runner(), this, CreateOAuthTokenGetter());
+}
+
scoped_refptr<network::SharedURLLoaderFactory>
ChromotingClientRuntime::url_loader_factory() {
DCHECK(network_task_runner()->BelongsToCurrentThread());