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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..05a05dd4cced8fed077f3c356d39a9cb87a57e1b
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/gcore/ChromeGoogleApiClientImpl.java
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.gcore;
+
+import android.content.Context;
+
+import com.google.android.gms.common.ConnectionResult;
+import com.google.android.gms.common.GooglePlayServicesUtil;
+import com.google.android.gms.common.api.GoogleApiClient;
+
+import org.chromium.base.Log;
+import org.chromium.base.TraceEvent;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default implementation for {@link ChromeGoogleApiClient}.
+ */
+public class ChromeGoogleApiClientImpl implements ChromeGoogleApiClient {
+ private static final String TAG = Log.makeTag("Icing");
+
+ private final Context mApplicationContext;
+ private final GoogleApiClient mClient;
+
+ /**
+ * @param context its application context will be exposed through
+ * {@link #getApplicationContext()}.
+ * @param client will be exposed through {@link #getApiClient()}.
+ */
+ public ChromeGoogleApiClientImpl(Context context, GoogleApiClient client) {
+ mApplicationContext = context.getApplicationContext();
+ mClient = client;
+ }
+
+ @Override
+ public void disconnect() {
+ mClient.disconnect();
+ }
+
+ @Override
+ public boolean isGooglePlayServicesAvailable() {
+ TraceEvent.begin("ChromeGoogleApiClientImpl:isGooglePlayServicesAvailable");
+ try {
+ int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(mApplicationContext);
+ return result == ConnectionResult.SUCCESS;
+ } finally {
+ TraceEvent.end("ChromeGoogleApiClientImpl:isGooglePlayServicesAvailable");
+ }
+ }
+
+ @Override
+ public boolean connectWithTimeout(long timeout) {
+ TraceEvent.begin("ChromeGoogleApiClientImpl:connectWithTimeout");
+ try {
+ ConnectionResult result = mClient.blockingConnect(timeout, TimeUnit.MILLISECONDS);
+ if (!result.isSuccess()) {
+ Log.e(TAG, "Connection to GmsCore unsuccessful. Error %d", result.getErrorCode());
+ } else {
+ Log.d(TAG, "Connection to GmsCore successful.");
+ }
+ return result.isSuccess();
+ } finally {
+ TraceEvent.end("ChromeGoogleApiClientImpl:connectWithTimeout");
+ }
+ }
+
+ public Context getApplicationContext() {
+ return mApplicationContext;
+ }
+
+ public GoogleApiClient getApiClient() {
+ return mClient;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698