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

Side by Side Diff: chrome/browser/supervised_user/permission_request_creator_apiary.h

Issue 592353002: PermissionRequestCreatorApiary: Support for multiple simultaneous requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/supervised_user/permission_request_creator_apiary.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ 6 #define CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
11 #include "chrome/browser/supervised_user/permission_request_creator.h" 12 #include "chrome/browser/supervised_user/permission_request_creator.h"
12 #include "google_apis/gaia/oauth2_token_service.h" 13 #include "google_apis/gaia/oauth2_token_service.h"
13 #include "net/url_request/url_fetcher_delegate.h" 14 #include "net/url_request/url_fetcher_delegate.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 class Profile; 17 class Profile;
17 class SupervisedUserSigninManagerWrapper; 18 class SupervisedUserSigninManagerWrapper;
18 19
19 namespace base { 20 namespace base {
20 class Time; 21 class Time;
(...skipping 15 matching lines...) Expand all
36 virtual ~PermissionRequestCreatorApiary(); 37 virtual ~PermissionRequestCreatorApiary();
37 38
38 static scoped_ptr<PermissionRequestCreator> CreateWithProfile( 39 static scoped_ptr<PermissionRequestCreator> CreateWithProfile(
39 Profile* profile); 40 Profile* profile);
40 41
41 // PermissionRequestCreator implementation: 42 // PermissionRequestCreator implementation:
42 virtual void CreatePermissionRequest(const GURL& url_requested, 43 virtual void CreatePermissionRequest(const GURL& url_requested,
43 const base::Closure& callback) OVERRIDE; 44 const base::Closure& callback) OVERRIDE;
44 45
45 private: 46 private:
47 struct Request {
48 Request(const GURL& url_requested, const base::Closure& callback);
49 ~Request();
50
51 GURL url_requested;
52 base::Closure callback;
53 scoped_ptr<OAuth2TokenService::Request> access_token_request;
54 std::string access_token;
Bernhard Bauer 2014/09/23 10:17:01 It's a bit weird that we store the access token pe
Marc Treib 2014/09/23 10:31:02 It's my understanding that access tokens are usual
Bernhard Bauer 2014/09/23 11:01:59 Well, short-lived means half an hour or so, I thin
Marc Treib 2014/09/23 11:08:43 Yeah, we could probably avoid explicitly storing t
55 bool access_token_expired;
56 scoped_ptr<net::URLFetcher> url_fetcher;
57 };
58 typedef ScopedVector<Request>::iterator RequestIterator;
59
46 // OAuth2TokenService::Consumer implementation: 60 // OAuth2TokenService::Consumer implementation:
47 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 61 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
48 const std::string& access_token, 62 const std::string& access_token,
49 const base::Time& expiration_time) OVERRIDE; 63 const base::Time& expiration_time) OVERRIDE;
50 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 64 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
51 const GoogleServiceAuthError& error) OVERRIDE; 65 const GoogleServiceAuthError& error) OVERRIDE;
52 66
53 // net::URLFetcherDelegate implementation. 67 // net::URLFetcherDelegate implementation.
54 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 68 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
55 69
56 std::string GetApiScopeToUse() const; 70 std::string GetApiScopeToUse() const;
57 71
58 // Requests an access token, which is the first thing we need. This is where 72 // Requests an access token, which is the first thing we need. This is where
59 // we restart when the returned access token has expired. 73 // we restart when the returned access token has expired.
60 void StartFetching(); 74 void StartFetching(Request* request);
61 75
62 void DispatchNetworkError(int error_code); 76 void DispatchNetworkError(RequestIterator it, int error_code);
63 void DispatchGoogleServiceAuthError(const GoogleServiceAuthError& error); 77 void DispatchGoogleServiceAuthError(RequestIterator it,
78 const GoogleServiceAuthError& error);
64 79
65 OAuth2TokenService* oauth2_token_service_; 80 OAuth2TokenService* oauth2_token_service_;
66 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_; 81 scoped_ptr<SupervisedUserSigninManagerWrapper> signin_wrapper_;
67 base::Closure callback_;
68 net::URLRequestContextGetter* context_; 82 net::URLRequestContextGetter* context_;
69 GURL url_requested_; 83
70 scoped_ptr<OAuth2TokenService::Request> access_token_request_; 84 ScopedVector<Request> requests_;
71 std::string access_token_;
72 bool access_token_expired_;
73 scoped_ptr<net::URLFetcher> url_fetcher_;
74 }; 85 };
75 86
76 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_ 87 #endif // CHROME_BROWSER_SUPERVISED_USER_PERMISSION_REQUEST_CREATOR_APIARY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/supervised_user/permission_request_creator_apiary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698