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

Side by Side Diff: utils/pub/oauth2.dart

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/path_source.dart » ('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 (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 oauth2; 5 library oauth2;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:uri'; 9 import 'dart:uri';
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return withClient(cache, fn); 97 return withClient(cache, fn);
98 } else { 98 } else {
99 throw error; 99 throw error;
100 } 100 }
101 }); 101 });
102 } 102 }
103 103
104 /// Gets a new OAuth2 client. If saved credentials are available, those are 104 /// Gets a new OAuth2 client. If saved credentials are available, those are
105 /// used; otherwise, the user is prompted to authorize the pub client. 105 /// used; otherwise, the user is prompted to authorize the pub client.
106 Future<Client> _getClient(SystemCache cache) { 106 Future<Client> _getClient(SystemCache cache) {
107 return new Future.of(() { 107 return new Future.sync(() {
108 var credentials = _loadCredentials(cache); 108 var credentials = _loadCredentials(cache);
109 if (credentials == null) return _authorize(); 109 if (credentials == null) return _authorize();
110 110
111 var client = new Client(_identifier, _secret, credentials, 111 var client = new Client(_identifier, _secret, credentials,
112 httpClient: httpClient); 112 httpClient: httpClient);
113 _saveCredentials(cache, client.credentials); 113 _saveCredentials(cache, client.credentials);
114 return client; 114 return client;
115 }); 115 });
116 } 116 }
117 117
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 response.statusCode = 404; 197 response.statusCode = 404;
198 response.close(); 198 response.close();
199 } 199 }
200 }); 200 });
201 }) 201 })
202 .then((client) { 202 .then((client) {
203 log.message('Successfully authorized.\n'); 203 log.message('Successfully authorized.\n');
204 return client; 204 return client;
205 }); 205 });
206 } 206 }
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/path_source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698