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