OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef REMOTING_CLIENT_JNI_CHROMOTING_JNI_H_ | 5 #ifndef REMOTING_CLIENT_JNI_CHROMOTING_JNI_H_ |
6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_H_ | 6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "net/url_request/url_request_context_getter.h" | 11 #include "net/url_request/url_request_context_getter.h" |
12 #include "remoting/base/auto_thread.h" | 12 #include "remoting/base/auto_thread.h" |
| 13 #include "remoting/client/jni/chromoting_jni_instance.h" |
13 #include "remoting/protocol/connection_to_host.h" | 14 #include "remoting/protocol/connection_to_host.h" |
14 | 15 |
15 template<typename T> struct DefaultSingletonTraits; | 16 template<typename T> struct DefaultSingletonTraits; |
16 | 17 |
17 namespace remoting { | 18 namespace remoting { |
18 class ChromotingJniInstance; | |
19 | 19 |
20 // Class and package name of the Java class supporting the methods we call. | 20 // Class and package name of the Java class supporting the methods we call. |
21 const char* const JAVA_CLASS = "org/chromium/chromoting/jni/JNIInterface"; | 21 const char* const JAVA_CLASS = "org/chromium/chromoting/jni/JNIInterface"; |
22 | 22 |
23 // Houses the global resources on which the Chromoting components run | 23 // Houses the global resources on which the Chromoting components run |
24 // (e.g. message loops and task runners). Proxies outgoing JNI calls from its | 24 // (e.g. message loops and task runners). Proxies outgoing JNI calls from its |
25 // ChromotingJniInstance member to Java. All its methods should be invoked | 25 // ChromotingJniInstance member to Java. All its methods should be invoked |
26 // exclusively from the UI thread. | 26 // exclusively from the UI thread unless otherwise noted. |
27 class ChromotingJni { | 27 class ChromotingJni { |
28 public: | 28 public: |
29 // This class is instantiated at process initialization and persists until | 29 // This class is instantiated at process initialization and persists until |
30 // we close. Its components are reused across |ChromotingJniInstance|s. | 30 // we close. Its components are reused across |ChromotingJniInstance|s. |
31 static ChromotingJni* GetInstance(); | 31 static ChromotingJni* GetInstance(); |
32 | 32 |
33 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() { | 33 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() { |
34 return ui_task_runner_; | 34 return ui_task_runner_; |
35 } | 35 } |
36 | 36 |
(...skipping 29 matching lines...) Expand all Loading... |
66 return session_; | 66 return session_; |
67 } | 67 } |
68 | 68 |
69 // Notifies the user that the connection status has changed. | 69 // Notifies the user that the connection status has changed. |
70 void ReportConnectionStatus(protocol::ConnectionToHost::State state, | 70 void ReportConnectionStatus(protocol::ConnectionToHost::State state, |
71 protocol::ErrorCode error); | 71 protocol::ErrorCode error); |
72 | 72 |
73 // Pops up a dialog box asking the user to enter a PIN. | 73 // Pops up a dialog box asking the user to enter a PIN. |
74 void DisplayAuthenticationPrompt(); | 74 void DisplayAuthenticationPrompt(); |
75 | 75 |
| 76 // Updates image dimensions and canvas memory space. Call on display thread. |
| 77 void UpdateImageBuffer(int width, int height, jobject buffer); |
| 78 |
| 79 // Draws the latest image buffer onto the canvas. Call on the display thread. |
| 80 void RedrawCanvas(); |
| 81 |
76 private: | 82 private: |
77 ChromotingJni(); | 83 ChromotingJni(); |
78 | 84 |
79 // Forces a DisconnectFromHost() in case there is any active or failed | 85 // Forces a DisconnectFromHost() in case there is any active or failed |
80 // connection, then proceeds to tear down the Chromium dependencies on which | 86 // connection, then proceeds to tear down the Chromium dependencies on which |
81 // all sessions depended. Because destruction only occurs at application exit | 87 // all sessions depended. Because destruction only occurs at application exit |
82 // after all connections have terminated, it is safe to make unretained | 88 // after all connections have terminated, it is safe to make unretained |
83 // cross-thread calls on the class. | 89 // cross-thread calls on the class. |
84 virtual ~ChromotingJni(); | 90 virtual ~ChromotingJni(); |
85 | 91 |
(...skipping 18 matching lines...) Expand all Loading... |
104 scoped_refptr<ChromotingJniInstance> session_; | 110 scoped_refptr<ChromotingJniInstance> session_; |
105 | 111 |
106 friend struct DefaultSingletonTraits<ChromotingJni>; | 112 friend struct DefaultSingletonTraits<ChromotingJni>; |
107 | 113 |
108 DISALLOW_COPY_AND_ASSIGN(ChromotingJni); | 114 DISALLOW_COPY_AND_ASSIGN(ChromotingJni); |
109 }; | 115 }; |
110 | 116 |
111 } // namespace remoting | 117 } // namespace remoting |
112 | 118 |
113 #endif | 119 #endif |
OLD | NEW |