Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: sky/viewer/content_handler_impl.cc

Issue 1154223003: NOT FOR COMMIT: POC of using AuthenticatingURLLoader in Sky (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: updated comment Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/viewer/BUILD.gn ('k') | sky/viewer/viewer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/viewer/content_handler_impl.cc
diff --git a/sky/viewer/content_handler_impl.cc b/sky/viewer/content_handler_impl.cc
index b36e4f7cbdc66e0cd07a0be2a9ea2a565da58dc8..39a8f0c4dc8d62846a39c72f5ec3cbdd5229e392 100644
--- a/sky/viewer/content_handler_impl.cc
+++ b/sky/viewer/content_handler_impl.cc
@@ -8,7 +8,8 @@
#include "mojo/public/cpp/application/connect.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/utility/run_loop.h"
-#include "mojo/services/network/public/interfaces/network_service.mojom.h"
+#include "mojo/services/authenticating_url_loader/public/interfaces/authenticating_url_loader_factory.mojom.h"
+#include "mojo/services/authentication/public/interfaces/authentication.mojom.h"
#include "sky/viewer/document_view.h"
namespace sky {
@@ -25,9 +26,16 @@ class SkyApplication : public mojo::Application {
const mojo::String& url) override {
shell_ = shell.Pass();
mojo::ServiceProviderPtr service_provider;
- shell_->ConnectToApplication("mojo:network_service",
+ shell_->ConnectToApplication("mojo:authenticating_url_loader",
mojo::GetProxy(&service_provider), nullptr);
- mojo::ConnectToService(service_provider.get(), &network_service_);
+ mojo::ConnectToService(service_provider.get(),
+ &authenticating_url_loader_factory_);
+ shell_->ConnectToApplication("mojo:authentication",
+ mojo::GetProxy(&service_provider), nullptr);
+ authentication::AuthenticationServicePtr authentication_service;
+ mojo::ConnectToService(service_provider.get(), &authentication_service);
+ authenticating_url_loader_factory_->SetAuthenticationService(
+ authentication_service.Pass());
}
void AcceptConnection(const mojo::String& requestor_url,
@@ -35,11 +43,12 @@ class SkyApplication : public mojo::Application {
mojo::ServiceProviderPtr exposed_services,
const mojo::String& url) override {
if (initial_response_) {
- OnResponseReceived(mojo::URLLoaderPtr(), services.Pass(),
+ OnResponseReceived(mojo::AuthenticatingURLLoaderPtr(), services.Pass(),
exposed_services.Pass(), initial_response_.Pass());
} else {
- mojo::URLLoaderPtr loader;
- network_service_->CreateURLLoader(mojo::GetProxy(&loader));
+ mojo::AuthenticatingURLLoaderPtr loader;
+ authenticating_url_loader_factory_->CreateAuthenticatingURLLoader(
+ mojo::GetProxy(&loader));
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = url;
request->auto_follow_redirects = true;
@@ -47,7 +56,7 @@ class SkyApplication : public mojo::Application {
// |loader| will be pass to the OnResponseReceived method through a
// callback. Because order of evaluation is undefined, a reference to the
// raw pointer is needed.
- mojo::URLLoader* raw_loader = loader.get();
+ mojo::AuthenticatingURLLoader* raw_loader = loader.get();
raw_loader->Start(
request.Pass(),
base::Bind(&SkyApplication::OnResponseReceived,
@@ -62,7 +71,7 @@ class SkyApplication : public mojo::Application {
private:
void OnResponseReceived(
- mojo::URLLoaderPtr loader,
+ mojo::AuthenticatingURLLoaderPtr loader,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services,
mojo::URLResponsePtr response) {
@@ -72,7 +81,7 @@ class SkyApplication : public mojo::Application {
mojo::StrongBinding<mojo::Application> binding_;
mojo::ShellPtr shell_;
- mojo::NetworkServicePtr network_service_;
+ mojo::AuthenticatingURLLoaderFactoryPtr authenticating_url_loader_factory_;
mojo::URLResponsePtr initial_response_;
};
« no previous file with comments | « sky/viewer/BUILD.gn ('k') | sky/viewer/viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698