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

Unified Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 34523003: settings: Make DeviceOAuth2TokenServiceFactory::Get() async (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
Index: chrome/browser/ui/webui/print_preview/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index 962e93b6c22268f7fbad69e4d51a769535f05cc6..cc9bb9c13d0672336454781a28d6a2c68a7507ca 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -373,7 +373,8 @@ class PrintPreviewHandler::AccessTokenService
: public OAuth2TokenService::Consumer {
public:
explicit AccessTokenService(PrintPreviewHandler* handler)
- : handler_(handler) {
+ : handler_(handler),
+ weak_factory_(this) {
}
void RequestToken(const std::string& type) {
@@ -392,13 +393,32 @@ class PrintPreviewHandler::AccessTokenService
}
} else if (type == "device") {
#if defined(OS_CHROMEOS)
- chromeos::DeviceOAuth2TokenService* token_service =
- chromeos::DeviceOAuth2TokenServiceFactory::Get();
- account_id = token_service->GetRobotAccountId();
- service = token_service;
+ chromeos::DeviceOAuth2TokenServiceFactory::Get(
+ base::Bind(
+ &PrintPreviewHandler::AccessTokenService::DidGetTokenService,
pneubeck (no reviews) 2013/10/22 09:05:03 PrintPreviewHandler:: really required? I thought q
satorux1 2013/10/22 09:56:43 good point. will fix.
satorux1 2013/10/23 06:35:44 Done.
+ weak_factory_.GetWeakPtr(),
+ type));
+ return;
#endif
}
+ ContinueRequestToken(type, service, account_id);
+ }
+
+#if defined(OS_CHROMEOS)
+ // Continuation of RequestToken().
+ void DidGetTokenService(const std::string& type,
+ chromeos::DeviceOAuth2TokenService* token_service) {
hashimoto 2013/10/22 08:49:51 nit: No need to have a NULL check here?
satorux1 2013/10/22 09:56:43 will add.
satorux1 2013/10/23 06:35:44 Done.
+ ContinueRequestToken(type,
+ token_service,
+ token_service->GetRobotAccountId());
+ }
+#endif
+
+ // Continuation of RequestToken().
+ void ContinueRequestToken(const std::string& type,
+ OAuth2TokenService* service,
+ const std::string& account_id) {
if (service) {
OAuth2TokenService::ScopeSet oauth_scopes;
oauth_scopes.insert(cloud_print::kCloudPrintAuth);
@@ -438,6 +458,7 @@ class PrintPreviewHandler::AccessTokenService
linked_ptr<OAuth2TokenService::Request> > Requests;
Requests requests_;
PrintPreviewHandler* handler_;
+ base::WeakPtrFactory<AccessTokenService> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AccessTokenService);
};

Powered by Google App Engine
This is Rietveld 408576698