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

Side by Side Diff: pkg/oauth2/lib/src/credentials.dart

Issue 11308111: Refactor http.Client and http.BaseClient to allow http.Client in type annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Small fix Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/oauth2/lib/src/client.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library credentials; 5 library credentials;
6 6
7 import 'dart:json'; 7 import 'dart:json';
8 import 'dart:uri'; 8 import 'dart:uri';
9 9
10 import '../../../http/lib/http.dart' as http; 10 import '../../../http/lib/http.dart' as http;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 /// You may request different scopes than the default by passing in 137 /// You may request different scopes than the default by passing in
138 /// [newScopes]. These must be a subset of [scopes]. 138 /// [newScopes]. These must be a subset of [scopes].
139 /// 139 ///
140 /// This will throw a [StateError] if these credentials can't be refreshed, an 140 /// This will throw a [StateError] if these credentials can't be refreshed, an
141 /// [AuthorizationException] if refreshing the credentials fails, or a 141 /// [AuthorizationException] if refreshing the credentials fails, or a
142 /// [FormatError] if the authorization server returns invalid responses. 142 /// [FormatError] if the authorization server returns invalid responses.
143 Future<Credentials> refresh( 143 Future<Credentials> refresh(
144 String identifier, 144 String identifier,
145 String secret, 145 String secret,
146 {List<String> newScopes, 146 {List<String> newScopes,
147 http.BaseClient httpClient}) { 147 http.Client httpClient}) {
148 var scopes = this.scopes; 148 var scopes = this.scopes;
149 if (newScopes != null) scopes = newScopes; 149 if (newScopes != null) scopes = newScopes;
150 if (scopes == null) scopes = <String>[]; 150 if (scopes == null) scopes = <String>[];
151 if (httpClient == null) httpClient = new http.Client(); 151 if (httpClient == null) httpClient = new http.Client();
152 152
153 var startTime = new Date.now(); 153 var startTime = new Date.now();
154 return async.chain((_) { 154 return async.chain((_) {
155 if (refreshToken == null) { 155 if (refreshToken == null) {
156 throw new StateError("Can't refresh credentials without a refresh " 156 throw new StateError("Can't refresh credentials without a refresh "
157 "token."); 157 "token.");
(...skipping 23 matching lines...) Expand all
181 if (credentials.refreshToken != null) return credentials; 181 if (credentials.refreshToken != null) return credentials;
182 return new Credentials( 182 return new Credentials(
183 credentials.accessToken, 183 credentials.accessToken,
184 this.refreshToken, 184 this.refreshToken,
185 credentials.tokenEndpoint, 185 credentials.tokenEndpoint,
186 credentials.scopes, 186 credentials.scopes,
187 credentials.expiration); 187 credentials.expiration);
188 }); 188 });
189 } 189 }
190 } 190 }
OLDNEW
« no previous file with comments | « pkg/oauth2/lib/src/client.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698