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

Side by Side Diff: remoting/client/jni/chromoting_jni_runtime.h

Issue 29583003: Use jni_generator in Chromoting Android client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Created 7 years, 1 month 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 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_RUNTIME_H_ 5 #ifndef REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_
6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ 6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/at_exit.h" 12 #include "base/at_exit.h"
13 #include "net/url_request/url_request_context_getter.h" 13 #include "net/url_request/url_request_context_getter.h"
14 #include "remoting/base/auto_thread.h" 14 #include "remoting/base/auto_thread.h"
15 #include "remoting/client/jni/chromoting_jni_instance.h" 15 #include "remoting/client/jni/chromoting_jni_instance.h"
16 #include "remoting/protocol/connection_to_host.h" 16 #include "remoting/protocol/connection_to_host.h"
17 17
18 template<typename T> struct DefaultSingletonTraits; 18 template<typename T> struct DefaultSingletonTraits;
19 19
20 namespace remoting { 20 namespace remoting {
21 21
22 bool RegisterJni(JNIEnv* env);
23
22 // Houses the global resources on which the Chromoting components run 24 // Houses the global resources on which the Chromoting components run
23 // (e.g. message loops and task runners). Proxies outgoing JNI calls from its 25 // (e.g. message loops and task runners). Proxies outgoing JNI calls from its
24 // ChromotingJniInstance member to Java. All its methods should be invoked 26 // ChromotingJniInstance member to Java. All its methods should be invoked
25 // exclusively from the UI thread unless otherwise noted. 27 // exclusively from the UI thread unless otherwise noted.
26 class ChromotingJniRuntime { 28 class ChromotingJniRuntime {
27 public: 29 public:
28 // This class is instantiated at process initialization and persists until 30 // This class is instantiated at process initialization and persists until
29 // we close. Its components are reused across |ChromotingJniInstance|s. 31 // we close. Its components are reused across |ChromotingJniInstance|s.
30 static ChromotingJniRuntime* GetInstance(); 32 static ChromotingJniRuntime* GetInstance();
31 33
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // Forces a DisconnectFromHost() in case there is any active or failed 102 // Forces a DisconnectFromHost() in case there is any active or failed
101 // connection, then proceeds to tear down the Chromium dependencies on which 103 // connection, then proceeds to tear down the Chromium dependencies on which
102 // all sessions depended. Because destruction only occurs at application exit 104 // all sessions depended. Because destruction only occurs at application exit
103 // after all connections have terminated, it is safe to make unretained 105 // after all connections have terminated, it is safe to make unretained
104 // cross-thread calls on the class. 106 // cross-thread calls on the class.
105 virtual ~ChromotingJniRuntime(); 107 virtual ~ChromotingJniRuntime();
106 108
107 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. 109 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|.
108 void DetachFromVmAndSignal(base::WaitableEvent* waiter); 110 void DetachFromVmAndSignal(base::WaitableEvent* waiter);
109 111
110 // Reference to the Java class into which we make JNI calls.
111 jclass class_;
112
113 // Used by the Chromium libraries to clean up the base and net libraries' JNI 112 // Used by the Chromium libraries to clean up the base and net libraries' JNI
114 // bindings. It must persist for the lifetime of the singleton. 113 // bindings. It must persist for the lifetime of the singleton.
115 scoped_ptr<base::AtExitManager> at_exit_manager_; 114 scoped_ptr<base::AtExitManager> at_exit_manager_;
116 115
117 // Chromium code's connection to the Java message loop. 116 // Chromium code's connection to the Java message loop.
118 scoped_ptr<base::MessageLoopForUI> ui_loop_; 117 scoped_ptr<base::MessageLoopForUI> ui_loop_;
119 118
120 // References to native threads. 119 // References to native threads.
121 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; 120 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
122 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; 121 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
123 scoped_refptr<AutoThreadTaskRunner> display_task_runner_; 122 scoped_refptr<AutoThreadTaskRunner> display_task_runner_;
124 123
125 scoped_refptr<net::URLRequestContextGetter> url_requester_; 124 scoped_refptr<net::URLRequestContextGetter> url_requester_;
126 125
127 // Contains all connection-specific state. 126 // Contains all connection-specific state.
128 scoped_refptr<ChromotingJniInstance> session_; 127 scoped_refptr<ChromotingJniInstance> session_;
129 128
130 friend struct DefaultSingletonTraits<ChromotingJniRuntime>; 129 friend struct DefaultSingletonTraits<ChromotingJniRuntime>;
131 130
132 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); 131 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime);
133 }; 132 };
134 133
135 } // namespace remoting 134 } // namespace remoting
136 135
137 #endif 136 #endif
OLDNEW
« no previous file with comments | « remoting/client/jni/chromoting_jni_onload.cc ('k') | remoting/client/jni/chromoting_jni_runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698