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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/jni/Client.java

Issue 2132883002: [Remoting Android] Placeholder for DesktopView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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.chromoting.jni; 5 package org.chromium.chromoting.jni;
6 6
7 import org.chromium.base.annotations.CalledByNative; 7 import org.chromium.base.annotations.CalledByNative;
8 import org.chromium.base.annotations.JNINamespace; 8 import org.chromium.base.annotations.JNINamespace;
9 import org.chromium.base.annotations.SuppressFBWarnings; 9 import org.chromium.base.annotations.SuppressFBWarnings;
10 import org.chromium.chromoting.CapabilityManager; 10 import org.chromium.chromoting.CapabilityManager;
11 import org.chromium.chromoting.DesktopViewFactory;
11 import org.chromium.chromoting.InputStub; 12 import org.chromium.chromoting.InputStub;
12 import org.chromium.chromoting.SessionAuthenticator; 13 import org.chromium.chromoting.SessionAuthenticator;
13 14
14 /** 15 /**
15 * Class to manage a client connection to the host. This class controls the life time of the 16 * Class to manage a client connection to the host. This class controls the life time of the
16 * corresponding C++ object which implements the connection. A new object should be created for 17 * corresponding C++ object which implements the connection. A new object should be created for
17 * each connection to the host, so that notifications from a connection are alwa ys sent to the 18 * each connection to the host, so that notifications from a connection are alwa ys sent to the
18 * right object. 19 * right object.
19 * This class is used entirely on the UI thread. 20 * This class is used entirely on the UI thread.
20 */ 21 */
21 @JNINamespace("remoting") 22 @JNINamespace("remoting")
22 public class Client implements InputStub { 23 public class Client implements InputStub {
23 // Pointer to the C++ object, cast to a |long|. 24 // Pointer to the C++ object, cast to a |long|.
24 private long mNativeJniClient; 25 private long mNativeJniClient;
25 26
26 // Implementation-dependent display object used by the desktop view. 27 // Implementation-dependent display object used by the desktop view.
27 private Object mDisplay; 28 private DesktopViewFactory mDisplay;
Lambros 2016/07/08 02:13:41 Can you fix the naming inconsistency somehow? Eith
Yuwei 2016/07/08 19:58:56 Logically speaking, this interface is just for cre
28 29
29 // The global Client instance (may be null). This needs to be a global singl eton so that the 30 // The global Client instance (may be null). This needs to be a global singl eton so that the
30 // Client can be passed between Activities. 31 // Client can be passed between Activities.
31 private static Client sClient; 32 private static Client sClient;
32 33
33 public Client() { 34 public Client() {
34 if (sClient != null) { 35 if (sClient != null) {
35 throw new RuntimeException("Client instance already created."); 36 throw new RuntimeException("Client instance already created.");
36 } 37 }
37 38
38 sClient = this; 39 sClient = this;
39 mNativeJniClient = nativeInit(); 40 mNativeJniClient = nativeInit();
40 } 41 }
41 42
42 /** 43 /**
43 * Sets the display object. Called by the native code when the connection st arts. 44 * Sets the display object. Called by the native code when the connection st arts.
44 * @param display the implementation-dependent object used by the desktop vi ew. 45 * @param display the implementation-dependent object used by the desktop vi ew.
45 */ 46 */
46 @CalledByNative 47 @CalledByNative
47 private void setDisplay(Object display) { 48 private void setDisplay(DesktopViewFactory display) {
48 mDisplay = display; 49 mDisplay = display;
49 } 50 }
50 51
51 /** 52 /**
52 * Returns the display object. It will be null before calling connectToHost( ) or after calling 53 * Returns the display object. It will be null before calling connectToHost( ) or after calling
53 * disconnectFromHost(). 54 * disconnectFromHost().
54 * @return the display object. 55 * @return the display object.
55 */ 56 */
56 public Object getDisplay() { 57 public DesktopViewFactory getDisplay() {
57 return mDisplay; 58 return mDisplay;
58 } 59 }
59 60
60 // Suppress FindBugs warning, since |sClient| is only used on the UI thread. 61 // Suppress FindBugs warning, since |sClient| is only used on the UI thread.
61 @SuppressFBWarnings("LI_LAZY_INIT_STATIC") 62 @SuppressFBWarnings("LI_LAZY_INIT_STATIC")
62 public void destroy() { 63 public void destroy() {
63 if (sClient != null) { 64 if (sClient != null) {
64 disconnectFromHost(); 65 disconnectFromHost();
65 nativeDestroy(mNativeJniClient); 66 nativeDestroy(mNativeJniClient);
66 sClient = null; 67 sClient = null;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 /** Passes touch event information to the native handling code. */ 336 /** Passes touch event information to the native handling code. */
336 private native void nativeSendTouchEvent( 337 private native void nativeSendTouchEvent(
337 long nativeJniClient, int eventType, TouchEventData[] data); 338 long nativeJniClient, int eventType, TouchEventData[] data);
338 339
339 /** Native implementation of Client.enableVideoChannel() */ 340 /** Native implementation of Client.enableVideoChannel() */
340 private native void nativeEnableVideoChannel(long nativeJniClient, boolean e nable); 341 private native void nativeEnableVideoChannel(long nativeJniClient, boolean e nable);
341 342
342 /** Passes extension message to the native code. */ 343 /** Passes extension message to the native code. */
343 private native void nativeSendExtensionMessage(long nativeJniClient, String type, String data); 344 private native void nativeSendExtensionMessage(long nativeJniClient, String type, String data);
344 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698