Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 package org.chromium.chromoting.jni; | 5 package org.chromium.chromoting.jni; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 | 8 |
| 9 import org.chromium.base.ContextUtils; | 9 import org.chromium.base.ContextUtils; |
| 10 import org.chromium.base.Log; | 10 import org.chromium.base.Log; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 sAccount = account; | 52 sAccount = account; |
| 53 fetchAuthToken(); | 53 fetchAuthToken(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Fetch the OAuth token and feed it to the native interface. | 57 * Fetch the OAuth token and feed it to the native interface. |
| 58 */ | 58 */ |
| 59 @CalledByNative | 59 @CalledByNative |
| 60 private static void fetchAuthToken() { | 60 private static void fetchAuthToken() { |
| 61 if (sAccount == null) { | 61 if (sAccount == null) { |
| 62 throw new IllegalStateException("Account is not set before fetching the auth token."); | 62 Log.w(TAG, "Account is not set before fetching the auth token."); |
|
Sergey Ulanov
2017/03/21 18:39:37
Maybe add a comment here to explain why we can ign
Yuwei
2017/03/21 19:02:24
Done.
| |
| 63 return; | |
| 63 } | 64 } |
| 64 sLoggerTokenConsumer.consume(sAccount, new OAuthTokenFetcher.Callback() { | 65 sLoggerTokenConsumer.consume(sAccount, new OAuthTokenFetcher.Callback() { |
| 65 @Override | 66 @Override |
| 66 public void onTokenFetched(String token) { | 67 public void onTokenFetched(String token) { |
| 67 nativeOnAuthTokenFetched(token); | 68 nativeOnAuthTokenFetched(token); |
| 68 } | 69 } |
| 69 | 70 |
| 70 @Override | 71 @Override |
| 71 public void onError(OAuthTokenFetcher.Error error) { | 72 public void onError(OAuthTokenFetcher.Error error) { |
| 72 Log.e(TAG, "Failed to fetch auth token for native client."); | 73 Log.e(TAG, "Failed to fetch auth token for native client."); |
| 73 } | 74 } |
| 74 }); | 75 }); |
| 75 } | 76 } |
| 76 | 77 |
| 77 /** Performs the native portion of the initialization. */ | 78 /** Performs the native portion of the initialization. */ |
| 78 private static native void nativeLoadNative(); | 79 private static native void nativeLoadNative(); |
| 79 | 80 |
| 80 /** Notifies the native client with the new auth token */ | 81 /** Notifies the native client with the new auth token */ |
| 81 private static native void nativeOnAuthTokenFetched(String token); | 82 private static native void nativeOnAuthTokenFetched(String token); |
| 82 } | 83 } |
| OLD | NEW |