OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_IMPL_H_ | 5 #ifndef SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_INTERCEPTOR
_H_ |
6 #define SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_IMPL_H_ | 6 #define SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_INTERCEPTOR
_H_ |
7 | 7 |
8 #include "mojo/public/cpp/bindings/binding.h" | 8 #include "mojo/public/cpp/bindings/binding.h" |
9 #include "mojo/public/cpp/bindings/error_handler.h" | 9 #include "mojo/public/cpp/bindings/error_handler.h" |
10 #include "mojo/services/authenticating_url_loader/public/interfaces/authenticati
ng_url_loader.mojom.h" | 10 #include "mojo/services/authenticating_url_loader/public/interfaces/authenticati
ng_url_loader.mojom.h" |
11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
12 #include "services/authenticating_url_loader/authenticating_url_loader_factory_i
mpl.h" | 12 #include "services/authenticating_url_loader/authenticating_url_loader_intercept
or_factory.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 | 16 |
17 class NetworkService; | 17 class NetworkService; |
18 | 18 |
19 enum RequestAuthorizationState { | 19 enum RequestAuthorizationState { |
20 REQUEST_INITIAL, | 20 REQUEST_INITIAL, |
21 REQUEST_USED_CURRENT_AUTH_SERVICE_TOKEN, | 21 REQUEST_USED_CURRENT_AUTH_SERVICE_TOKEN, |
22 REQUEST_USED_FRESH_AUTH_SERVICE_TOKEN, | 22 REQUEST_USED_FRESH_AUTH_SERVICE_TOKEN, |
23 }; | 23 }; |
24 | 24 |
25 class AuthenticatingURLLoaderImpl : public AuthenticatingURLLoader, | 25 class AuthenticatingURLLoaderInterceptor : public URLLoaderInterceptor, |
26 public ErrorHandler { | 26 public ErrorHandler { |
27 public: | 27 public: |
28 AuthenticatingURLLoaderImpl(InterfaceRequest<AuthenticatingURLLoader> request, | 28 AuthenticatingURLLoaderInterceptor( |
29 AuthenticatingURLLoaderFactoryImpl* factory); | 29 mojo::InterfaceRequest<URLLoaderInterceptor> request, |
30 ~AuthenticatingURLLoaderImpl() override; | 30 AuthenticatingURLLoaderInterceptorFactory* factory); |
| 31 ~AuthenticatingURLLoaderInterceptor() override; |
31 | 32 |
32 private: | 33 private: |
33 // AuthenticatingURLLoader methods: | 34 // URLLoaderInterceptor: |
34 void Start(URLRequestPtr request, | 35 void InterceptRequest(mojo::URLRequestPtr request, |
35 const Callback<void(URLResponsePtr)>& callback) override; | 36 const InterceptRequestCallback& callback) override; |
36 void FollowRedirect(const Callback<void(URLResponsePtr)>& callback) override; | 37 void InterceptFollowRedirect( |
| 38 const InterceptResponseCallback& callback) override; |
| 39 void InterceptResponse(mojo::URLResponsePtr response, |
| 40 const InterceptResponseCallback& callback) override; |
37 | 41 |
38 // ErrorHandler methods: | 42 // ErrorHandler: |
39 void OnConnectionError() override; | 43 void OnConnectionError() override; |
40 | 44 |
41 void StartNetworkRequest(URLRequestPtr request); | |
42 | |
43 void OnLoadComplete(URLResponsePtr response); | |
44 | |
45 void FollowRedirectInternal(); | |
46 | |
47 void OnOAuth2TokenReceived(std::string token); | 45 void OnOAuth2TokenReceived(std::string token); |
48 | 46 |
49 Binding<AuthenticatingURLLoader> binding_; | 47 URLRequestPtr BuildRequest(std::string token); |
50 AuthenticatingURLLoaderFactoryImpl* factory_; | 48 void StartRequest(mojo::URLRequestPtr request); |
51 URLLoaderPtr url_loader_; | 49 |
| 50 Binding<URLLoaderInterceptor> binding_; |
| 51 AuthenticatingURLLoaderInterceptorFactory* factory_; |
| 52 InterceptResponseCallback pending_interception_callback_; |
52 URLResponsePtr pending_response_; | 53 URLResponsePtr pending_response_; |
53 RequestAuthorizationState request_authorization_state_; | 54 RequestAuthorizationState request_authorization_state_; |
54 GURL url_; | 55 GURL url_; |
55 bool auto_follow_redirects_; | 56 bool auto_follow_redirects_; |
56 bool bypass_cache_; | 57 bool bypass_cache_; |
57 Array<HttpHeaderPtr> headers_; | 58 Array<HttpHeaderPtr> headers_; |
58 Callback<void(URLResponsePtr)> pending_request_callback_; | |
59 }; | 59 }; |
60 | 60 |
61 } // namespace mojo | 61 } // namespace mojo |
62 | 62 |
63 #endif // SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_IMPL_H_ | 63 #endif // SERVICES_AUTHENTICATING_URL_LOADER_AUTHENTICATING_URL_LOADER_INTERCEP
TOR_H_ |
OLD | NEW |