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

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

Issue 1764503002: Adding container class for chromoting client runtimes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing ios version, using runtime in jni runtime. Created 4 years, 9 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 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
(...skipping 16 matching lines...) Expand all
27 // (e.g. message loops and task runners). Proxies outgoing JNI calls from its 27 // (e.g. message loops and task runners). Proxies outgoing JNI calls from its
28 // ChromotingJniInstance member to Java. All its methods should be invoked 28 // ChromotingJniInstance member to Java. All its methods should be invoked
29 // exclusively from the UI thread unless otherwise noted. 29 // exclusively from the UI thread unless otherwise noted.
30 class ChromotingJniRuntime { 30 class ChromotingJniRuntime {
31 public: 31 public:
32 // This class is instantiated at process initialization and persists until 32 // This class is instantiated at process initialization and persists until
33 // we close. Its components are reused across |ChromotingJniInstance|s. 33 // we close. Its components are reused across |ChromotingJniInstance|s.
34 static ChromotingJniRuntime* GetInstance(); 34 static ChromotingJniRuntime* GetInstance();
35 35
36 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() { 36 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() {
37 return ui_task_runner_; 37 return runtime_-ui_task_runner();
nicholss 2016/03/07 18:41:56 Doing this to be backwards compatible.
38 } 38 }
39 39
40 scoped_refptr<AutoThreadTaskRunner> network_task_runner() { 40 scoped_refptr<AutoThreadTaskRunner> network_task_runner() {
41 return network_task_runner_; 41 return runtime_->network_task_runner();
42 } 42 }
43 43
44 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { 44 scoped_refptr<AutoThreadTaskRunner> display_task_runner() {
45 return display_task_runner_; 45 return runtime_->display_task_runner();
46 } 46 }
47 47
48 scoped_refptr<net::URLRequestContextGetter> url_requester() { 48 scoped_refptr<net::URLRequestContextGetter> url_requester() {
49 return url_requester_; 49 return runtime_->url_requester();
50 } 50 }
51 51
52 // Initiates a connection with the specified host. Only call when a host 52 // Initiates a connection with the specified host. Only call when a host
53 // connection is active (i.e. between a call to Connect() and the 53 // connection is active (i.e. between a call to Connect() and the
54 // corresponding call to Disconnect()). To skip the attempt at pair-based 54 // corresponding call to Disconnect()). To skip the attempt at pair-based
55 // authentication, leave |pairing_id| and |pairing_secret| as empty strings. 55 // authentication, leave |pairing_id| and |pairing_secret| as empty strings.
56 void ConnectToHost(const std::string& username, 56 void ConnectToHost(const std::string& username,
57 const std::string& auth_token, 57 const std::string& auth_token,
58 const std::string& host_jid, 58 const std::string& host_jid,
59 const std::string& host_id, 59 const std::string& host_id,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Forces a DisconnectFromHost() in case there is any active or failed 119 // Forces a DisconnectFromHost() in case there is any active or failed
120 // connection, then proceeds to tear down the Chromium dependencies on which 120 // connection, then proceeds to tear down the Chromium dependencies on which
121 // all sessions depended. Because destruction only occurs at application exit 121 // all sessions depended. Because destruction only occurs at application exit
122 // after all connections have terminated, it is safe to make unretained 122 // after all connections have terminated, it is safe to make unretained
123 // cross-thread calls on the class. 123 // cross-thread calls on the class.
124 virtual ~ChromotingJniRuntime(); 124 virtual ~ChromotingJniRuntime();
125 125
126 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. 126 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|.
127 void DetachFromVmAndSignal(base::WaitableEvent* waiter); 127 void DetachFromVmAndSignal(base::WaitableEvent* waiter);
128 128
129 // Chromium code's connection to the Java message loop. 129 // Contains threads.
130 scoped_ptr<base::MessageLoopForUI> ui_loop_; 130 //
131 131 ChromotingClientRuntime* runtime_;
132 // References to native threads.
133 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
134 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
135 scoped_refptr<AutoThreadTaskRunner> display_task_runner_;
136
137 scoped_refptr<net::URLRequestContextGetter> url_requester_;
138 132
139 // Contains all connection-specific state. 133 // Contains all connection-specific state.
140 scoped_refptr<ChromotingJniInstance> session_; 134 scoped_refptr<ChromotingJniInstance> session_;
141 135
142 friend struct base::DefaultSingletonTraits<ChromotingJniRuntime>; 136 friend struct base::DefaultSingletonTraits<ChromotingJniRuntime>;
143 137
144 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); 138 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime);
145 }; 139 };
146 140
147 } // namespace remoting 141 } // namespace remoting
148 142
149 #endif 143 #endif
OLDNEW
« no previous file with comments | « remoting/client/chromoting_client_runtime.cc ('k') | remoting/client/jni/chromoting_jni_runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698