OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.gcore; | 5 package org.chromium.chrome.browser.gcore; |
6 | 6 |
7 import android.os.Bundle; | 7 import android.os.Bundle; |
8 import android.os.Handler; | 8 import android.os.Handler; |
9 | 9 |
10 import com.google.android.gms.common.ConnectionResult; | 10 import com.google.android.gms.common.ConnectionResult; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 * | 64 * |
65 * // It still has to be disconnected if it's not done already. | 65 * // It still has to be disconnected if it's not done already. |
66 * client.disconnect(); | 66 * client.disconnect(); |
67 * } | 67 * } |
68 * </pre> | 68 * </pre> |
69 */ | 69 */ |
70 public class GoogleApiClientHelper | 70 public class GoogleApiClientHelper |
71 implements OnConnectionFailedListener, ConnectionCallbacks { | 71 implements OnConnectionFailedListener, ConnectionCallbacks { |
72 private static final String TAG = "GCore"; | 72 private static final String TAG = "GCore"; |
73 | 73 |
74 private int mResolutionAttempts = 0; | 74 private int mResolutionAttempts; |
75 private boolean mWasConnectedBefore = false; | 75 private boolean mWasConnectedBefore; |
76 private final Handler mHandler = new Handler(ThreadUtils.getUiThreadLooper()
); | 76 private final Handler mHandler = new Handler(ThreadUtils.getUiThreadLooper()
); |
77 private final GoogleApiClient mClient; | 77 private final GoogleApiClient mClient; |
78 private long mDisconnectionDelayMs = 0; | 78 private long mDisconnectionDelayMs; |
79 private Runnable mPendingDisconnect; | 79 private Runnable mPendingDisconnect; |
80 | 80 |
81 /** | 81 /** |
82 * Creates a helper and enrolls it in the various connection management feat
ures. | 82 * Creates a helper and enrolls it in the various connection management feat
ures. |
83 * See the class documentation for {@link GoogleApiClientHelper} for more in
formation. | 83 * See the class documentation for {@link GoogleApiClientHelper} for more in
formation. |
84 * | 84 * |
85 * @param client The client to wrap. | 85 * @param client The client to wrap. |
86 */ | 86 */ |
87 public GoogleApiClientHelper(GoogleApiClient client) { | 87 public GoogleApiClientHelper(GoogleApiClient client) { |
88 mClient = client; | 88 mClient = client; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // for some reason. | 240 // for some reason. |
241 Log.w(TAG, "Managed client connection suspended. Cause: %d", cause); | 241 Log.w(TAG, "Managed client connection suspended. Cause: %d", cause); |
242 } | 242 } |
243 | 243 |
244 private static boolean isErrorRecoverableByRetrying(int errorCode) { | 244 private static boolean isErrorRecoverableByRetrying(int errorCode) { |
245 return errorCode == ConnectionResult.INTERNAL_ERROR | 245 return errorCode == ConnectionResult.INTERNAL_ERROR |
246 || errorCode == ConnectionResult.NETWORK_ERROR | 246 || errorCode == ConnectionResult.NETWORK_ERROR |
247 || errorCode == ConnectionResult.SERVICE_UPDATING; | 247 || errorCode == ConnectionResult.SERVICE_UPDATING; |
248 } | 248 } |
249 } | 249 } |
OLD | NEW |