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

Unified Diff: services/location/src/org/chromium/services/location/LocationServiceApp.java

Issue 1309233008: Move applications using play services to the shell. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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: services/location/src/org/chromium/services/location/LocationServiceApp.java
diff --git a/services/location/src/org/chromium/services/location/LocationServiceApp.java b/services/location/src/org/chromium/services/location/LocationServiceApp.java
deleted file mode 100644
index f82608f664364737537efd02ba1066ac2577dda0..0000000000000000000000000000000000000000
--- a/services/location/src/org/chromium/services/location/LocationServiceApp.java
+++ /dev/null
@@ -1,142 +0,0 @@
-// 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.services.location;
-
-import android.content.Context;
-import android.os.Looper;
-import android.util.Log;
-
-import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.location.LocationServices;
-
-import org.chromium.mojo.application.ApplicationConnection;
-import org.chromium.mojo.application.ApplicationDelegate;
-import org.chromium.mojo.application.ApplicationRunner;
-import org.chromium.mojo.application.ServiceFactoryBinder;
-import org.chromium.mojo.bindings.InterfaceRequest;
-import org.chromium.mojo.system.Core;
-import org.chromium.mojo.system.MessagePipeHandle;
-import org.chromium.mojom.mojo.LocationService;
-import org.chromium.mojom.mojo.Shell;
-
-/**
- * Android service application implementing the LocationService interface using Google play
- * services API.
- */
-class LocationServiceApp implements ApplicationDelegate {
- private static final String TAG = "LocationServiceApp";
-
- private final GoogleApiClient mGoogleApiClient;
- private final Core mCore;
-
- /**
- * Android looper thread class to get callbacks from google play services api.
- */
- private static class LooperThread extends Thread {
- private Looper mLooper;
-
- @Override
- public void run() {
- synchronized (this) {
- Looper.prepare();
- mLooper = Looper.myLooper();
- this.notify();
- }
- Looper.loop();
- }
-
- public Looper getLooper() {
- synchronized (this) {
- while (mLooper == null) {
- try {
- this.wait();
- } catch (InterruptedException e) {
- Log.e(TAG, e.getMessage(), e);
- }
- }
- }
- return mLooper;
- }
-
- public void quitSoon() {
- synchronized (this) {
- while (mLooper == null) {
- try {
- this.wait();
- } catch (InterruptedException e) {
- Log.e(TAG, e.getMessage(), e);
- }
- }
- }
- mLooper.quitSafely();
- }
- }
- private final LooperThread mLooperThread = new LooperThread();
-
- public LocationServiceApp(Context context, Core core) {
- // TODO(alhaad): Create a test mode which uses mock locations instead of real locations.
- mGoogleApiClient =
- new GoogleApiClient.Builder(context).addApi(LocationServices.API).build();
- mCore = core;
- }
-
- /**
- * @see ApplicationDelegate#initialize(Shell, String[], String)
- */
- @Override
- public void initialize(Shell shell, String[] args, String url) {
- ConnectionResult connectionResult = mGoogleApiClient.blockingConnect();
- if (!connectionResult.isSuccess()) {
- Log.e(TAG, "Could not connect to Google play services. ConnectionResult: "
- + connectionResult.toString());
- mCore.getCurrentRunLoop().quit();
- return;
- }
- mLooperThread.start();
- }
-
- /**
- * @see ApplicationDelegate#configureIncomingConnection(ApplicationConnection)
- */
- @Override
- public boolean configureIncomingConnection(ApplicationConnection connection) {
- connection.addService(new ServiceFactoryBinder<LocationService>() {
- @Override
- public void bind(InterfaceRequest<LocationService> request) {
- LocationService.MANAGER.bind(
- new LocationServiceImpl(mGoogleApiClient, mLooperThread.getLooper(),
- mCore.getCurrentRunLoop()),
- request);
- }
-
- @Override
- public String getInterfaceName() {
- return LocationService.MANAGER.getName();
- }
- });
- return true;
- }
-
- /**
- * @see ApplicationDelegate#quit()
- */
- @Override
- public void quit() {
- mGoogleApiClient.disconnect();
- mLooperThread.quitSoon();
- try {
- mLooperThread.join();
- } catch (InterruptedException e) {
- Log.e(TAG, e.getMessage(), e);
- }
- }
-
- public static void mojoMain(
- Context context, Core core, MessagePipeHandle applicationRequestHandle) {
- ApplicationRunner.run(
- new LocationServiceApp(context, core), core, applicationRequestHandle);
- }
-}
« no previous file with comments | « services/location/src/org/chromium/services/location/LocationApplicationDelegate.java ('k') | shell/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698