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

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

Issue 2753963002: Refactoring and rewriting the chromoting jni instance to be chromoting session. (Closed)
Patch Set: JNI client is the session delegate. Created 3 years, 8 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 #ifndef REMOTING_CLIENT_JNI_JNI_CLIENT_H_ 5 #ifndef REMOTING_CLIENT_JNI_JNI_CLIENT_H_
6 #define REMOTING_CLIENT_JNI_JNI_CLIENT_H_ 6 #define REMOTING_CLIENT_JNI_JNI_CLIENT_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "remoting/protocol/connection_to_host.h" 13 #include "remoting/protocol/connection_to_host.h"
14 #include "remoting/protocol/cursor_shape_stub.h" 14 #include "remoting/protocol/cursor_shape_stub.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 class AudioPlayerAndroid;
18 class ChromotingClientRuntime; 19 class ChromotingClientRuntime;
19 class ChromotingJniInstance; 20 class ChromotingSession::Delegate;
21 class ChromotingSession;
20 class JniGlDisplayHandler; 22 class JniGlDisplayHandler;
21 class JniPairingSecretFetcher; 23 class JniPairingSecretFetcher;
22 24
23 struct ConnectToHostInfo; 25 struct ConnectToHostInfo;
24 26
25 // Houses resources scoped to a session and exposes JNI interface to the 27 // Houses resources scoped to a session and exposes JNI interface to the
26 // Java client during a session. All its methods should be invoked exclusively 28 // Java client during a session. All its methods should be invoked exclusively
27 // from the UI thread unless otherwise noted. 29 // from the UI thread unless otherwise noted.
28 class JniClient { 30 class JniClient : public ChromotingSession::Delegate {
29 public: 31 public:
30 JniClient(base::android::ScopedJavaGlobalRef<jobject> java_client); 32 JniClient(base::android::ScopedJavaGlobalRef<jobject> java_client);
31 virtual ~JniClient(); 33 virtual ~JniClient();
32 34
33 // Initiates a connection with the specified host. To skip the attempt at 35 // Initiates a connection with the specified host. To skip the attempt at
34 // pair-based authentication, leave |pairing_id| and |pairing_secret| as 36 // pair-based authentication, leave |pairing_id| and |pairing_secret| as
35 // empty strings. 37 // empty strings.
36 void ConnectToHost(const ConnectToHostInfo& info); 38 void ConnectToHost(const ConnectToHostInfo& info);
37 39
38 // Terminates any ongoing connection attempt and cleans up by nullifying 40 // Terminates any ongoing connection attempt and cleans up by nullifying
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // consider handling task posting inside the client. 149 // consider handling task posting inside the client.
148 base::WeakPtr<JniClient> GetWeakPtr(); 150 base::WeakPtr<JniClient> GetWeakPtr();
149 151
150 private: 152 private:
151 ChromotingClientRuntime* runtime_; 153 ChromotingClientRuntime* runtime_;
152 154
153 // Reference to the Java client object. 155 // Reference to the Java client object.
154 base::android::ScopedJavaGlobalRef<jobject> java_client_; 156 base::android::ScopedJavaGlobalRef<jobject> java_client_;
155 157
156 std::unique_ptr<JniGlDisplayHandler> display_handler_; 158 std::unique_ptr<JniGlDisplayHandler> display_handler_;
159 std::unique_ptr<AudioPlayerAndroid> audio_player_;
157 160
158 // Deleted on UI thread. 161 // Deleted on UI thread.
159 std::unique_ptr<JniPairingSecretFetcher> secret_fetcher_; 162 std::unique_ptr<JniPairingSecretFetcher> secret_fetcher_;
160 163
161 // Deleted on Network thread. 164 // Deleted on Network thread.
162 std::unique_ptr<ChromotingJniInstance> session_; 165 std::unique_ptr<ChromotingSession> session_;
163 166
164 // Holds pointer for the UI thread. 167 // Holds pointer for the UI thread.
165 base::WeakPtr<JniClient> weak_ptr_; 168 base::WeakPtr<JniClient> weak_ptr_;
166 base::WeakPtrFactory<JniClient> weak_factory_; 169 base::WeakPtrFactory<JniClient> weak_factory_;
167 170
168 DISALLOW_COPY_AND_ASSIGN(JniClient); 171 DISALLOW_COPY_AND_ASSIGN(JniClient);
169 }; 172 };
170 173
171 } // namespace remoting 174 } // namespace remoting
172 175
173 #endif // REMOTING_CLIENT_JNI_JNI_CLIENT_H_ 176 #endif // REMOTING_CLIENT_JNI_JNI_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698