OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ | |
6 #define REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <string> | |
10 | |
11 #include "base/at_exit.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/message_loop/message_loop.h" | |
15 #include "net/url_request/url_request_context_getter.h" | |
16 #include "remoting/base/auto_thread.h" | |
17 #include "remoting/client/client_user_interface.h" | |
18 | |
19 template<typename T> struct DefaultSingletonTraits; | |
20 | |
21 // Class and package name of the Java class supporting the methods we call. | |
22 const char* const JAVA_CLASS="org/chromium/chromoting/jni/JNIInterface"; | |
23 | |
24 namespace remoting { | |
25 | |
26 // ClientUserInterface that makes and (indirectly) receives JNI calls. | |
27 class ChromotingJNIInstance | |
28 : public ClientUserInterface { | |
garykac
2013/07/10 21:56:18
nit: doesn't this fit on one line?
solb
2013/07/10 22:11:57
Done.
| |
29 public: | |
30 static ChromotingJNIInstance* GetInstance(); | |
31 | |
32 // Call from UI thread. | |
33 void ConnectToHost( | |
34 jstring username, | |
35 jstring auth_token, | |
36 jstring host_jid, | |
37 jstring host_id, | |
38 jstring host_pubkey); | |
39 | |
40 // Call from UI thread. | |
41 void DisconnectFromHost(); | |
42 | |
43 // ClientUserInterface implementation: | |
44 virtual void OnConnectionState( | |
45 protocol::ConnectionToHost::State state, | |
46 protocol::ErrorCode error) OVERRIDE; | |
47 virtual void OnConnectionReady(bool ready) OVERRIDE; | |
48 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; | |
49 virtual void SetPairingResponse( | |
50 const protocol::PairingResponse& response) OVERRIDE; | |
51 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE; | |
52 virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE; | |
53 virtual scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> | |
54 GetTokenFetcher(const std::string& host_public_key) OVERRIDE; | |
55 | |
56 private: | |
57 ChromotingJNIInstance(); | |
58 virtual ~ChromotingJNIInstance(); | |
59 | |
60 // reusable between sessions: | |
garykac
2013/07/10 21:56:18
nit: Reusable
solb
2013/07/10 22:11:57
Done.
| |
61 jclass class_; // Reference to the Java class into which we make JNI calls. | |
62 scoped_ptr<base::AtExitManager> collector_; | |
63 scoped_ptr<base::MessageLoopForUI> ui_loop_; | |
64 scoped_refptr<AutoThreadTaskRunner> ui_runner_; | |
65 scoped_refptr<AutoThreadTaskRunner> net_runner_; | |
66 scoped_refptr<AutoThreadTaskRunner> disp_runner_; | |
67 scoped_refptr<net::URLRequestContextGetter> url_requester_; | |
68 | |
69 // Java string handles: | |
70 jstring username_jstr_; | |
71 jstring auth_token_jstr_; | |
72 jstring host_jid_jstr_; | |
73 jstring host_id_jstr_; | |
74 jstring host_pubkey_jstr_; | |
75 jstring pin_jstr_; | |
76 | |
77 // C string pointers: | |
78 const char* username_cstr_; | |
79 const char* auth_token_cstr_; | |
80 const char* host_jid_cstr_; | |
81 const char* host_id_cstr_; | |
82 const char* host_pubkey_cstr_; | |
83 const char* pin_cstr_; | |
84 | |
85 friend struct DefaultSingletonTraits<ChromotingJNIInstance>; | |
86 | |
87 DISALLOW_COPY_AND_ASSIGN(ChromotingJNIInstance); | |
88 }; | |
89 | |
90 } // namespace remoting | |
91 | |
92 #endif | |
OLD | NEW |