| 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 // It is safe to ignore this request since setAccountForLogging() wi
ll be called later | 62 throw new IllegalStateException("Account is not set before fetching
the auth token."); |
| 63 // and will request the auth token. Logs will be queued up and sent
once the auth token | |
| 64 // is set. | |
| 65 Log.w(TAG, "Account is not set before fetching the auth token."); | |
| 66 return; | |
| 67 } | 63 } |
| 68 sLoggerTokenConsumer.consume(sAccount, new OAuthTokenFetcher.Callback()
{ | 64 sLoggerTokenConsumer.consume(sAccount, new OAuthTokenFetcher.Callback()
{ |
| 69 @Override | 65 @Override |
| 70 public void onTokenFetched(String token) { | 66 public void onTokenFetched(String token) { |
| 71 nativeOnAuthTokenFetched(token); | 67 nativeOnAuthTokenFetched(token); |
| 72 } | 68 } |
| 73 | 69 |
| 74 @Override | 70 @Override |
| 75 public void onError(OAuthTokenFetcher.Error error) { | 71 public void onError(OAuthTokenFetcher.Error error) { |
| 76 Log.e(TAG, "Failed to fetch auth token for native client."); | 72 Log.e(TAG, "Failed to fetch auth token for native client."); |
| 77 } | 73 } |
| 78 }); | 74 }); |
| 79 } | 75 } |
| 80 | 76 |
| 81 /** Performs the native portion of the initialization. */ | 77 /** Performs the native portion of the initialization. */ |
| 82 private static native void nativeLoadNative(); | 78 private static native void nativeLoadNative(); |
| 83 | 79 |
| 84 /** Notifies the native client with the new auth token */ | 80 /** Notifies the native client with the new auth token */ |
| 85 private static native void nativeOnAuthTokenFetched(String token); | 81 private static native void nativeOnAuthTokenFetched(String token); |
| 86 } | 82 } |
| OLD | NEW |