Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.gcore;
6
7 import android.content.Context;
8
9 import com.google.android.gms.common.ConnectionResult;
10 import com.google.android.gms.common.GooglePlayServicesUtil;
11 import com.google.android.gms.common.api.GoogleApiClient;
12
13 import org.chromium.base.Log;
14 import org.chromium.base.TraceEvent;
15
16 import java.util.concurrent.TimeUnit;
17
18 /**
19 * Default implementation for {@link ChromeGoogleApiClient}.
20 */
21 public class ChromeGoogleApiClientImpl implements ChromeGoogleApiClient {
22 private static final String TAG = Log.makeTag("Icing");
23
24 private final Context mApplicationContext;
25 private final GoogleApiClient mClient;
26
27 /**
28 * @param context its application context will be exposed through
29 * {@link #getApplicationContext()}.
30 * @param client will be exposed through {@link #getApiClient()}.
31 */
32 public ChromeGoogleApiClientImpl(Context context, GoogleApiClient client) {
33 mApplicationContext = context.getApplicationContext();
34 mClient = client;
35 }
36
37 @Override
38 public void disconnect() {
39 mClient.disconnect();
40 }
41
42 @Override
43 public boolean isGooglePlayServicesAvailable() {
44 TraceEvent.begin("ChromeGoogleApiClientImpl:isGooglePlayServicesAvailabl e");
45 try {
46 int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(mA pplicationContext);
47 return result == ConnectionResult.SUCCESS;
48 } finally {
49 TraceEvent.end("ChromeGoogleApiClientImpl:isGooglePlayServicesAvaila ble");
50 }
51 }
52
53 @Override
54 public boolean connectWithTimeout(long timeout) {
55 TraceEvent.begin("ChromeGoogleApiClientImpl:connectWithTimeout");
56 try {
57 ConnectionResult result = mClient.blockingConnect(timeout, TimeUnit. MILLISECONDS);
58 if (!result.isSuccess()) {
59 Log.e(TAG, "Connection to GmsCore unsuccessful. Error %d", resul t.getErrorCode());
60 } else {
61 Log.d(TAG, "Connection to GmsCore successful.");
62 }
63 return result.isSuccess();
64 } finally {
65 TraceEvent.end("ChromeGoogleApiClientImpl:connectWithTimeout");
66 }
67 }
68
69 public Context getApplicationContext() {
70 return mApplicationContext;
71 }
72
73 public GoogleApiClient getApiClient() {
74 return mClient;
75 }
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698