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 : public ClientUserInterface { | |
Wez
2013/07/11 00:56:23
Having ChromotingJNIInstance be a singleton, and i
solb
2013/07/11 04:29:05
Yes, we can only handle a single *concurrent* conn
| |
28 public: | |
29 static ChromotingJNIInstance* GetInstance(); | |
Wez
2013/07/11 00:56:23
nit: Add a comment to explain this, e.g. why it on
solb
2013/07/11 04:29:05
Done.
| |
30 | |
31 // Call from UI thread. | |
Wez
2013/07/11 00:56:23
See Google C++ style guide for comment style requi
solb
2013/07/11 04:29:05
Done.
| |
32 void ConnectToHost( | |
33 jstring username, | |
34 jstring auth_token, | |
35 jstring host_jid, | |
36 jstring host_id, | |
37 jstring host_pubkey); | |
38 | |
39 // Call from UI thread. | |
40 void DisconnectFromHost(); | |
41 | |
42 // ClientUserInterface implementation: | |
Wez
2013/07/11 00:56:23
nit: : -> .
solb
2013/07/11 04:29:05
Done.
| |
43 virtual void OnConnectionState( | |
44 protocol::ConnectionToHost::State state, | |
45 protocol::ErrorCode error) OVERRIDE; | |
46 virtual void OnConnectionReady(bool ready) OVERRIDE; | |
47 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; | |
48 virtual void SetPairingResponse( | |
49 const protocol::PairingResponse& response) OVERRIDE; | |
50 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE; | |
51 virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE; | |
52 virtual scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> | |
53 GetTokenFetcher(const std::string& host_public_key) OVERRIDE; | |
54 | |
55 private: | |
56 ChromotingJNIInstance(); | |
57 virtual ~ChromotingJNIInstance(); | |
58 | |
59 // Reusable between sessions: | |
Wez
2013/07/11 00:56:23
As above, : -> . and see style guide re comment st
solb
2013/07/11 04:29:05
Done.
| |
60 jclass class_; // Reference to the Java class into which we make JNI calls. | |
61 scoped_ptr<base::AtExitManager> collector_; | |
62 scoped_ptr<base::MessageLoopForUI> ui_loop_; | |
Wez
2013/07/11 00:56:23
Add a comment to explain what |ui_loop_| is for, i
solb
2013/07/11 04:29:05
Done.
| |
63 scoped_refptr<AutoThreadTaskRunner> ui_runner_; | |
Wez
2013/07/11 00:56:23
nit: ui_task_runner_
solb
2013/07/11 04:29:05
Done.
| |
64 scoped_refptr<AutoThreadTaskRunner> net_runner_; | |
Wez
2013/07/11 00:56:23
nit: network_task_runner_
solb
2013/07/11 04:29:05
Done.
| |
65 scoped_refptr<AutoThreadTaskRunner> disp_runner_; | |
Wez
2013/07/11 00:56:23
nit: display_task_runner_
solb
2013/07/11 04:29:05
Done.
| |
66 scoped_refptr<net::URLRequestContextGetter> url_requester_; | |
67 | |
68 // Java string handles: | |
69 jstring username_jstr_; | |
70 jstring auth_token_jstr_; | |
71 jstring host_jid_jstr_; | |
72 jstring host_id_jstr_; | |
73 jstring host_pubkey_jstr_; | |
74 jstring pin_jstr_; | |
75 | |
76 // C string pointers: | |
77 const char* username_cstr_; | |
78 const char* auth_token_cstr_; | |
79 const char* host_jid_cstr_; | |
80 const char* host_id_cstr_; | |
81 const char* host_pubkey_cstr_; | |
82 const char* pin_cstr_; | |
Wez
2013/07/11 00:56:23
Replace these and the jstring references with std:
solb
2013/07/11 04:29:05
Done.
| |
83 | |
84 friend struct DefaultSingletonTraits<ChromotingJNIInstance>; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(ChromotingJNIInstance); | |
87 }; | |
88 | |
89 } // namespace remoting | |
90 | |
91 #endif | |
OLD | NEW |