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_RUNTIME_H_ |
6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_H_ | 6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_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/client/jni/chromoting_jni_instance.h" |
14 #include "remoting/protocol/connection_to_host.h" | 14 #include "remoting/protocol/connection_to_host.h" |
15 | 15 |
16 template<typename T> struct DefaultSingletonTraits; | 16 template<typename T> struct DefaultSingletonTraits; |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 // Houses the global resources on which the Chromoting components run | 20 // Houses the global resources on which the Chromoting components run |
21 // (e.g. message loops and task runners). Proxies outgoing JNI calls from its | 21 // (e.g. message loops and task runners). Proxies outgoing JNI calls from its |
22 // ChromotingJniInstance member to Java. All its methods should be invoked | 22 // ChromotingJniInstance member to Java. All its methods should be invoked |
23 // exclusively from the UI thread unless otherwise noted. | 23 // exclusively from the UI thread unless otherwise noted. |
24 class ChromotingJni { | 24 class ChromotingJniRuntime { |
25 public: | 25 public: |
26 // This class is instantiated at process initialization and persists until | 26 // This class is instantiated at process initialization and persists until |
27 // we close. Its components are reused across |ChromotingJniInstance|s. | 27 // we close. Its components are reused across |ChromotingJniInstance|s. |
28 static ChromotingJni* GetInstance(); | 28 static ChromotingJniRuntime* GetInstance(); |
29 | 29 |
30 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() { | 30 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() { |
31 return ui_task_runner_; | 31 return ui_task_runner_; |
32 } | 32 } |
33 | 33 |
34 scoped_refptr<AutoThreadTaskRunner> network_task_runner() { | 34 scoped_refptr<AutoThreadTaskRunner> network_task_runner() { |
35 return network_task_runner_; | 35 return network_task_runner_; |
36 } | 36 } |
37 | 37 |
38 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { | 38 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Pops up a dialog box asking the user to enter a PIN. | 70 // Pops up a dialog box asking the user to enter a PIN. |
71 void DisplayAuthenticationPrompt(); | 71 void DisplayAuthenticationPrompt(); |
72 | 72 |
73 // Updates image dimensions and canvas memory space. Call on display thread. | 73 // Updates image dimensions and canvas memory space. Call on display thread. |
74 void UpdateImageBuffer(int width, int height, jobject buffer); | 74 void UpdateImageBuffer(int width, int height, jobject buffer); |
75 | 75 |
76 // Draws the latest image buffer onto the canvas. Call on the display thread. | 76 // Draws the latest image buffer onto the canvas. Call on the display thread. |
77 void RedrawCanvas(); | 77 void RedrawCanvas(); |
78 | 78 |
79 private: | 79 private: |
80 ChromotingJni(); | 80 ChromotingJniRuntime(); |
81 | 81 |
82 // Forces a DisconnectFromHost() in case there is any active or failed | 82 // Forces a DisconnectFromHost() in case there is any active or failed |
83 // connection, then proceeds to tear down the Chromium dependencies on which | 83 // connection, then proceeds to tear down the Chromium dependencies on which |
84 // all sessions depended. Because destruction only occurs at application exit | 84 // all sessions depended. Because destruction only occurs at application exit |
85 // after all connections have terminated, it is safe to make unretained | 85 // after all connections have terminated, it is safe to make unretained |
86 // cross-thread calls on the class. | 86 // cross-thread calls on the class. |
87 virtual ~ChromotingJni(); | 87 virtual ~ChromotingJniRuntime(); |
88 | 88 |
89 // Reference to the Java class into which we make JNI calls. | 89 // Reference to the Java class into which we make JNI calls. |
90 jclass class_; | 90 jclass class_; |
91 | 91 |
92 // Used by the Chromium libraries to clean up the base and net libraries' JNI | 92 // Used by the Chromium libraries to clean up the base and net libraries' JNI |
93 // bindings. It must persist for the lifetime of the singleton. | 93 // bindings. It must persist for the lifetime of the singleton. |
94 scoped_ptr<base::AtExitManager> at_exit_manager_; | 94 scoped_ptr<base::AtExitManager> at_exit_manager_; |
95 | 95 |
96 // Chromium code's connection to the Java message loop. | 96 // Chromium code's connection to the Java message loop. |
97 scoped_ptr<base::MessageLoopForUI> ui_loop_; | 97 scoped_ptr<base::MessageLoopForUI> ui_loop_; |
98 | 98 |
99 // References to native threads. | 99 // References to native threads. |
100 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; | 100 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; |
101 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; | 101 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; |
102 scoped_refptr<AutoThreadTaskRunner> display_task_runner_; | 102 scoped_refptr<AutoThreadTaskRunner> display_task_runner_; |
103 | 103 |
104 scoped_refptr<net::URLRequestContextGetter> url_requester_; | 104 scoped_refptr<net::URLRequestContextGetter> url_requester_; |
105 | 105 |
106 // Contains all connection-specific state. | 106 // Contains all connection-specific state. |
107 scoped_refptr<ChromotingJniInstance> session_; | 107 scoped_refptr<ChromotingJniInstance> session_; |
108 | 108 |
109 friend struct DefaultSingletonTraits<ChromotingJni>; | 109 friend struct DefaultSingletonTraits<ChromotingJniRuntime>; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(ChromotingJni); | 111 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); |
112 }; | 112 }; |
113 | 113 |
114 } // namespace remoting | 114 } // namespace remoting |
115 | 115 |
116 #endif | 116 #endif |
OLD | NEW |