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

Unified Diff: services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc

Issue 1185563003: Move AuthenticatingURLLoader app from ErrorHandler to callbacks (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Response to review Created 5 years, 6 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 | « services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc
diff --git a/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc b/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc
index 5e8eafc53729543d3f80cce235121602a5f3227b..b488f1cb07e7df05be94f69200bf74b80f25ffa9 100644
--- a/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc
+++ b/services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.cc
@@ -23,7 +23,8 @@ AuthenticatingURLLoaderInterceptorFactory::
app_(app),
cached_tokens_(cached_tokens) {
app_->ConnectToService("mojo:network_service", &network_service_);
- authentication_service_.set_error_handler(this);
+ authentication_service_.set_connection_error_handler(
+ [this]() { ClearAuthenticationService(); });
}
AuthenticatingURLLoaderInterceptorFactory::
@@ -71,7 +72,7 @@ void AuthenticatingURLLoaderInterceptorFactory::RetrieveToken(
}
}
-void AuthenticatingURLLoaderInterceptorFactory::OnInterceptorError(
+void AuthenticatingURLLoaderInterceptorFactory::ClearInterceptor(
AuthenticatingURLLoaderInterceptor* interceptor) {
auto it = std::find_if(
interceptors_.begin(), interceptors_.end(),
@@ -83,7 +84,7 @@ void AuthenticatingURLLoaderInterceptorFactory::OnInterceptorError(
interceptors_.erase(it);
}
-void AuthenticatingURLLoaderInterceptorFactory::OnConnectionError() {
+void AuthenticatingURLLoaderInterceptorFactory::ClearAuthenticationService() {
authentication_service_ = nullptr;
// All pending requests need to fail.
@@ -97,8 +98,12 @@ void AuthenticatingURLLoaderInterceptorFactory::OnConnectionError() {
void AuthenticatingURLLoaderInterceptorFactory::Create(
mojo::InterfaceRequest<URLLoaderInterceptor> interceptor) {
- interceptors_.push_back(std::unique_ptr<AuthenticatingURLLoaderInterceptor>(
- new AuthenticatingURLLoaderInterceptor(interceptor.Pass(), this)));
+ std::unique_ptr<AuthenticatingURLLoaderInterceptor> interceptor_impl(
+ new AuthenticatingURLLoaderInterceptor(interceptor.Pass(), this));
+ interceptor_impl->set_connection_error_handler(base::Bind(
+ &AuthenticatingURLLoaderInterceptorFactory::ClearInterceptor,
+ base::Unretained(this), base::Unretained(interceptor_impl.get())));
+ interceptors_.push_back(std::move(interceptor_impl));
}
void AuthenticatingURLLoaderInterceptorFactory::OnAccountSelected(
« no previous file with comments | « services/authenticating_url_loader_interceptor/authenticating_url_loader_interceptor_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698