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

Unified Diff: chrome/browser/chromeos/arc/arc_auth_code_fetcher.h

Issue 2498363002: Remove delegates from ArcAuthCodeFetcher and ArcAuthContext. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 | « chrome/browser/chromeos/BUILD.gn ('k') | chrome/browser/chromeos/arc/arc_auth_code_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/arc_auth_code_fetcher.h
diff --git a/chrome/browser/chromeos/arc/arc_auth_code_fetcher.h b/chrome/browser/chromeos/arc/arc_auth_code_fetcher.h
index c514602e32540424672c3683ad89c62d32e0827a..751cb25e9e86c5685a4193e6e1ec1080e1416d69 100644
--- a/chrome/browser/chromeos/arc/arc_auth_code_fetcher.h
+++ b/chrome/browser/chromeos/arc/arc_auth_code_fetcher.h
@@ -8,7 +8,10 @@
#include <memory>
#include <string>
+#include "base/callback.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/chromeos/arc/arc_auth_context.h"
#include "google_apis/gaia/oauth2_token_service.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -21,17 +24,21 @@ class URLRequestContextGetter;
namespace arc {
-class ArcAuthCodeFetcherDelegate;
-
+// The instance is not reusable, so for each Fetch(), the instance must be
+// re-created. Deleting the instance cancels inflight operation.
class ArcAuthCodeFetcher : public OAuth2TokenService::Consumer,
public net::URLFetcherDelegate {
public:
- ArcAuthCodeFetcher(ArcAuthCodeFetcherDelegate* delegate,
- net::URLRequestContextGetter* request_context_getter,
- Profile* profile,
+ ArcAuthCodeFetcher(Profile* profile,
+ ArcAuthContext* context,
const std::string& auth_endpoint);
~ArcAuthCodeFetcher() override;
+ // Starts to fetch the token. On success fetched |auth_token| is passed.
+ // On error, auth_token is empty.
+ using FetchCallback = base::Callback<void(const std::string& auth_token)>;
+ void Fetch(const FetchCallback& callback);
+
// OAuth2TokenService::Consumer:
void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
const std::string& access_token,
@@ -44,18 +51,23 @@ class ArcAuthCodeFetcher : public OAuth2TokenService::Consumer,
private:
void ResetFetchers();
+ void OnPrepared(net::URLRequestContextGetter* request_context_getter);
// Unowned pointers.
- ArcAuthCodeFetcherDelegate* const delegate_;
- net::URLRequestContextGetter* const request_context_getter_;
Profile* const profile_;
+ ArcAuthContext* const context_;
+ net::URLRequestContextGetter* request_context_getter_ = nullptr;
// URL to request auth code.
const std::string auth_endpoint_;
+ FetchCallback callback_;
+
std::unique_ptr<OAuth2TokenService::Request> login_token_request_;
std::unique_ptr<net::URLFetcher> auth_code_fetcher_;
+ base::WeakPtrFactory<ArcAuthCodeFetcher> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ArcAuthCodeFetcher);
};
« no previous file with comments | « chrome/browser/chromeos/BUILD.gn ('k') | chrome/browser/chromeos/arc/arc_auth_code_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698