OLD | NEW |
---|---|
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_CHROMOTING_JNI_INSTANCE_H_ | 5 #ifndef REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ |
6 #define REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ | 6 #define REMOTING_CLIENT_CHROMOTING_JNI_INSTANCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "remoting/client/chromoting_client.h" | 13 #include "remoting/client/chromoting_client.h" |
14 #include "remoting/client/client_config.h" | 14 #include "remoting/client/client_config.h" |
15 #include "remoting/client/client_context.h" | 15 #include "remoting/client/client_context.h" |
16 #include "remoting/client/client_user_interface.h" | 16 #include "remoting/client/client_user_interface.h" |
17 #include "remoting/client/frame_consumer_proxy.h" | 17 #include "remoting/client/frame_consumer_proxy.h" |
18 #include "remoting/client/jni/frame_consumer_impl.h" | |
18 #include "remoting/jingle_glue/network_settings.h" | 19 #include "remoting/jingle_glue/network_settings.h" |
19 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 20 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
20 #include "remoting/protocol/connection_to_host.h" | 21 #include "remoting/protocol/connection_to_host.h" |
21 | 22 |
22 namespace remoting { | 23 namespace remoting { |
23 class ChromotingJni; | |
24 | 24 |
25 // TODO(solb) Move into location shared with client plugin. | 25 // TODO(solb) Move into location shared with client plugin. |
26 const char* const CHAT_SERVER = "talk.google.com"; | 26 const char* const CHAT_SERVER = "talk.google.com"; |
27 const int CHAT_PORT = 5222; | 27 const int CHAT_PORT = 5222; |
28 const bool CHAT_USE_TLS = true; | 28 const bool CHAT_USE_TLS = true; |
29 const char* const CHAT_AUTH_METHOD = "oauth2"; | 29 const char* const CHAT_AUTH_METHOD = "oauth2"; |
30 | 30 |
31 // ClientUserInterface that indirectly makes and receives JNI calls. | 31 // ClientUserInterface that indirectly makes and receives JNI calls. |
32 class ChromotingJniInstance | 32 class ChromotingJniInstance |
33 : public ClientUserInterface, | 33 : public ClientUserInterface, |
34 public base::RefCountedThreadSafe<ChromotingJniInstance> { | 34 public base::RefCountedThreadSafe<ChromotingJniInstance> { |
35 public: | 35 public: |
36 // Initiates a connection with the specified host. Call from the UI thread. | 36 // Initiates a connection with the specified host. Call from the UI thread. |
37 ChromotingJniInstance( | 37 ChromotingJniInstance( |
38 const char* username, | 38 const char* username, |
39 const char* auth_token, | 39 const char* auth_token, |
40 const char* host_jid, | 40 const char* host_jid, |
41 const char* host_id, | 41 const char* host_id, |
42 const char* host_pubkey); | 42 const char* host_pubkey); |
43 | 43 |
44 // Terminates the current connection (if it hasn't already failed) and cleans | 44 // Terminates the current connection (if it hasn't already failed) and cleans |
45 // up. Must be called before destruction. | 45 // up. Must be called before destruction. |
46 void Cleanup(); | 46 void Cleanup(); |
47 | 47 |
48 // Provides the user's PIN and resumes the host authentication attempt. Call | 48 // Provides the user's PIN and resumes the host authentication attempt. Call |
49 // on the UI thread once the user has finished entering this PIN into the UI, | 49 // on the UI thread once the user has finished entering this PIN into the UI, |
50 // but only after the UI has been asked to provide a PIN (via FetchSecret()). | 50 // but only after the UI has been asked to provide a PIN (via FetchSecret()). |
51 void ProvideSecret(const char* pin); | 51 void ProvideSecret(const char* pin); |
52 | 52 |
53 // Schedules a redraw on the display thread. May be called from any thread. | |
54 void RedrawGraphics(); | |
Wez
2013/07/16 02:18:12
nit: RedrawCanvas, for consistency w/ ChromotingJn
solb
2013/07/16 18:00:57
Done.
| |
55 | |
53 // ClientUserInterface implementation. | 56 // ClientUserInterface implementation. |
54 virtual void OnConnectionState( | 57 virtual void OnConnectionState( |
55 protocol::ConnectionToHost::State state, | 58 protocol::ConnectionToHost::State state, |
56 protocol::ErrorCode error) OVERRIDE; | 59 protocol::ErrorCode error) OVERRIDE; |
57 virtual void OnConnectionReady(bool ready) OVERRIDE; | 60 virtual void OnConnectionReady(bool ready) OVERRIDE; |
58 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; | 61 virtual void SetCapabilities(const std::string& capabilities) OVERRIDE; |
59 virtual void SetPairingResponse( | 62 virtual void SetPairingResponse( |
60 const protocol::PairingResponse& response) OVERRIDE; | 63 const protocol::PairingResponse& response) OVERRIDE; |
61 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE; | 64 virtual protocol::ClipboardStub* GetClipboardStub() OVERRIDE; |
62 virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE; | 65 virtual protocol::CursorShapeStub* GetCursorShapeStub() OVERRIDE; |
63 virtual scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> | 66 virtual scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher> |
64 GetTokenFetcher(const std::string& host_public_key) OVERRIDE; | 67 GetTokenFetcher(const std::string& host_public_key) OVERRIDE; |
65 | 68 |
66 private: | 69 private: |
67 // This object is ref-counted, so it cleans itself up. | 70 // This object is ref-counted, so it cleans itself up. |
68 virtual ~ChromotingJniInstance(); | 71 virtual ~ChromotingJniInstance(); |
69 | 72 |
70 void ConnectToHostOnDisplayThread(); | 73 void ConnectToHostOnDisplayThread(); |
71 void ConnectToHostOnNetworkThread(); | 74 void ConnectToHostOnNetworkThread(); |
72 | 75 |
73 // Notifies the user interface that the user needs to enter a PIN. The | 76 // Notifies the user interface that the user needs to enter a PIN. The |
74 // current authentication attempt is put on hold until |callback| is invoked. | 77 // current authentication attempt is put on hold until |callback| is invoked. |
78 // May be called on any thread. | |
75 void FetchSecret(bool pairable, | 79 void FetchSecret(bool pairable, |
76 const protocol::SecretFetchedCallback& callback); | 80 const protocol::SecretFetchedCallback& callback); |
77 | 81 |
82 // This group of variables is to be used on the display thread. | |
78 scoped_refptr<FrameConsumerProxy> frame_consumer_; | 83 scoped_refptr<FrameConsumerProxy> frame_consumer_; |
84 scoped_ptr<FrameConsumerImpl> view_; | |
79 | 85 |
80 // This group of variables is to be used on the network thread. | 86 // This group of variables is to be used on the network thread. |
81 scoped_ptr<ClientConfig> client_config_; | 87 scoped_ptr<ClientConfig> client_config_; |
82 scoped_ptr<ClientContext> client_context_; | 88 scoped_ptr<ClientContext> client_context_; |
83 scoped_ptr<protocol::ConnectionToHost> connection_; | 89 scoped_ptr<protocol::ConnectionToHost> connection_; |
84 scoped_ptr<ChromotingClient> client_; | 90 scoped_ptr<ChromotingClient> client_; |
85 scoped_ptr<XmppSignalStrategy::XmppServerConfig> signaling_config_; | 91 scoped_ptr<XmppSignalStrategy::XmppServerConfig> signaling_config_; |
86 scoped_ptr<XmppSignalStrategy> signaling_; // Must outlive client_ | 92 scoped_ptr<XmppSignalStrategy> signaling_; // Must outlive client_ |
87 scoped_ptr<NetworkSettings> network_settings_; | 93 scoped_ptr<NetworkSettings> network_settings_; |
88 | 94 |
(...skipping 12 matching lines...) Expand all Loading... | |
101 std::string host_pubkey_; | 107 std::string host_pubkey_; |
102 | 108 |
103 friend class base::RefCountedThreadSafe<ChromotingJniInstance>; | 109 friend class base::RefCountedThreadSafe<ChromotingJniInstance>; |
104 | 110 |
105 DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); | 111 DISALLOW_COPY_AND_ASSIGN(ChromotingJniInstance); |
106 }; | 112 }; |
107 | 113 |
108 } // namespace remoting | 114 } // namespace remoting |
109 | 115 |
110 #endif | 116 #endif |
OLD | NEW |