| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/gdata/auth_service.h" | 5 #include "chrome/browser/chromeos/gdata/auth_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 scoped_refptr<base::MessageLoopProxy> relay_proxy, | 80 scoped_refptr<base::MessageLoopProxy> relay_proxy, |
| 81 const AuthStatusCallback& callback) { | 81 const AuthStatusCallback& callback) { |
| 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 83 // We have refresh token, let's gets authenticated. | 83 // We have refresh token, let's gets authenticated. |
| 84 (new AuthOperation(registry, callback, refresh_token_))->Start(); | 84 (new AuthOperation(registry, callback, refresh_token_))->Start(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void AuthService::OnAuthCompleted( | 87 void AuthService::OnAuthCompleted( |
| 88 scoped_refptr<base::MessageLoopProxy> relay_proxy, | 88 scoped_refptr<base::MessageLoopProxy> relay_proxy, |
| 89 const AuthStatusCallback& callback, | 89 const AuthStatusCallback& callback, |
| 90 GDataErrorCode error, | 90 DriveErrorCode error, |
| 91 const std::string& access_token) { | 91 const std::string& access_token) { |
| 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 93 | 93 |
| 94 if (error == HTTP_SUCCESS) | 94 if (error == HTTP_SUCCESS) |
| 95 access_token_ = access_token; | 95 access_token_ = access_token; |
| 96 | 96 |
| 97 // TODO(zelidrag): Add retry, back-off logic when things go wrong here. | 97 // TODO(zelidrag): Add retry, back-off logic when things go wrong here. |
| 98 if (!callback.is_null()) | 98 if (!callback.is_null()) |
| 99 relay_proxy->PostTask(FROM_HERE, base::Bind(callback, error, access_token)); | 99 relay_proxy->PostTask(FROM_HERE, base::Bind(callback, error, access_token)); |
| 100 } | 100 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 122 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) { | 122 if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) { |
| 123 TokenService* service = TokenServiceFactory::GetForProfile(profile_); | 123 TokenService* service = TokenServiceFactory::GetForProfile(profile_); |
| 124 refresh_token_ = service->GetOAuth2LoginRefreshToken(); | 124 refresh_token_ = service->GetOAuth2LoginRefreshToken(); |
| 125 } else { | 125 } else { |
| 126 refresh_token_.clear(); | 126 refresh_token_.clear(); |
| 127 } | 127 } |
| 128 FOR_EACH_OBSERVER(Observer, observers_, OnOAuth2RefreshTokenChanged()); | 128 FOR_EACH_OBSERVER(Observer, observers_, OnOAuth2RefreshTokenChanged()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace gdata | 131 } // namespace gdata |
| OLD | NEW |