Refactor Future constructors.

BUG=

Review URL: https://codereview.chromium.org//14070010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21517 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/src/client.dart b/lib/src/client.dart
index 0d422af..ec8dda5 100644
--- a/lib/src/client.dart
+++ b/lib/src/client.dart
@@ -83,7 +83,7 @@
   /// the request if necessary.
   Future<http.StreamedResponse> send(http.BaseRequest request) {
     return async.then((_) {
-      if (!credentials.isExpired) return new Future.immediate(null);
+      if (!credentials.isExpired) return new Future.value();
       if (!credentials.canRefresh) throw new ExpirationException(credentials);
       return refreshCredentials();
     }).then((_) {
diff --git a/test/authorization_code_grant_test.dart b/test/authorization_code_grant_test.dart
index dead690..22be3cf 100644
--- a/test/authorization_code_grant_test.dart
+++ b/test/authorization_code_grant_test.dart
@@ -154,7 +154,7 @@
           'client_secret': 'secret'
         }));
 
-        return new Future.immediate(new http.Response(JSON.stringify({
+        return new Future.value(new http.Response(JSON.stringify({
           'access_token': 'access token',
           'token_type': 'bearer',
         }), 200, headers: {'content-type': 'application/json'}));
@@ -198,7 +198,7 @@
           'client_secret': 'secret'
         }));
 
-        return new Future.immediate(new http.Response(JSON.stringify({
+        return new Future.value(new http.Response(JSON.stringify({
           'access_token': 'access token',
           'token_type': 'bearer',
         }), 200, headers: {'content-type': 'application/json'}));
diff --git a/test/client_test.dart b/test/client_test.dart
index 434ea95..bac0548 100644
--- a/test/client_test.dart
+++ b/test/client_test.dart
@@ -57,7 +57,7 @@
       httpClient.expectRequest((request) {
         expect(request.method, equals('POST'));
         expect(request.url.toString(), equals(tokenEndpoint.toString()));
-        return new Future.immediate(new http.Response(JSON.stringify({
+        return new Future.value(new http.Response(JSON.stringify({
           'access_token': 'new access token',
           'token_type': 'bearer'
         }), 200, headers: {'content-type': 'application/json'}));
@@ -69,7 +69,7 @@
         expect(request.headers['authorization'],
             equals('Bearer new access token'));
 
-        return new Future.immediate(new http.Response('good job', 200));
+        return new Future.value(new http.Response('good job', 200));
       });
 
       expect(client.read(requestUri).then((_) {
@@ -92,7 +92,7 @@
         expect(request.headers['authorization'],
             equals('Bearer access token'));
 
-        return new Future.immediate(new http.Response('good job', 200));
+        return new Future.value(new http.Response('good job', 200));
       });
 
       expect(client.read(requestUri), completion(equals('good job')));
@@ -107,7 +107,7 @@
       httpClient.expectRequest((request) {
         expect(request.method, equals('POST'));
         expect(request.url.toString(), equals(tokenEndpoint.toString()));
-        return new Future.immediate(new http.Response(JSON.stringify({
+        return new Future.value(new http.Response(JSON.stringify({
           'access_token': 'new access token',
           'token_type': 'bearer'
         }), 200, headers: {'content-type': 'application/json'}));
@@ -144,7 +144,7 @@
 
         var authenticate = 'Bearer error="invalid_token", error_description='
             '"Something is terribly wrong."';
-        return new Future.immediate(new http.Response('bad job', 401,
+        return new Future.value(new http.Response('bad job', 401,
                 headers: {'www-authenticate': authenticate}));
       });
 
@@ -163,7 +163,7 @@
         expect(request.headers['authorization'],
             equals('Bearer access token'));
 
-        return new Future.immediate(new http.Response('bad job', 401));
+        return new Future.value(new http.Response('bad job', 401));
       });
 
       expect(
@@ -184,7 +184,7 @@
 
         var authenticate = 'Bearer error="invalid_token", error_description='
           '"Something is terribly wrong.", ';
-        return new Future.immediate(new http.Response('bad job', 401,
+        return new Future.value(new http.Response('bad job', 401,
                 headers: {'www-authenticate': authenticate}));
       });
 
@@ -204,7 +204,7 @@
         expect(request.headers['authorization'],
             equals('Bearer access token'));
 
-        return new Future.immediate(new http.Response('bad job', 401,
+        return new Future.value(new http.Response('bad job', 401,
                 headers: {'www-authenticate': 'Digest'}));
       });
 
@@ -224,7 +224,7 @@
         expect(request.headers['authorization'],
             equals('Bearer access token'));
 
-        return new Future.immediate(new http.Response('bad job', 401,
+        return new Future.value(new http.Response('bad job', 401,
                 headers: {'www-authenticate': 'Bearer'}));
       });
 
diff --git a/test/credentials_test.dart b/test/credentials_test.dart
index 1ee5b75..652d394 100644
--- a/test/credentials_test.dart
+++ b/test/credentials_test.dart
@@ -76,7 +76,7 @@
         "client_secret": "secret"
       }));
 
-      return new Future.immediate(new http.Response(JSON.stringify({
+      return new Future.value(new http.Response(JSON.stringify({
         'access_token': 'new access token',
         'token_type': 'bearer',
         'refresh_token': 'new refresh token'
@@ -106,7 +106,7 @@
         "client_secret": "secret"
       }));
 
-      return new Future.immediate(new http.Response(JSON.stringify({
+      return new Future.value(new http.Response(JSON.stringify({
         'access_token': 'new access token',
         'token_type': 'bearer'
       }), 200, headers: {'content-type': 'application/json'}));
diff --git a/test/utils.dart b/test/utils.dart
index b874cc4..9198c80 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -38,7 +38,7 @@
 
   Future<http.Response> _handleRequest(http.Request request) {
     if (_handlers.isEmpty) {
-      return new Future.immediate(new http.Response('not found', 404));
+      return new Future.value(new http.Response('not found', 404));
     } else {
       return _handlers.removeFirst()(request);
     }