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

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

Issue 2745583008: Refactoring out the chromoting jni runtime class in favor of chromoting client runtime. (Closed)
Patch Set: Unit tests need to link with android. Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_PAIRING_SECRET_FETCHER_H_ 5 #ifndef REMOTING_CLIENT_JNI_JNI_PAIRING_SECRET_FETCHER_H_
6 #define REMOTING_CLIENT_JNI_JNI_PAIRING_SECRET_FETCHER_H_ 6 #define REMOTING_CLIENT_JNI_JNI_PAIRING_SECRET_FETCHER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "remoting/protocol/client_authentication_config.h" 10 #include "remoting/protocol/client_authentication_config.h"
11 11
12 namespace remoting { 12 namespace remoting {
13 13
14 class ChromotingJniRuntime; 14 class ChromotingClientRuntime;
15 class JniClient; 15 class JniClient;
16 16
17 // This class fetches the pairing secret on the UI thread. This should be 17 // This class fetches the pairing secret on the UI thread. This should be
18 // created on the UI thread but there after used and deleted on the network 18 // created on the UI thread but there after used and deleted on the network
19 // thread. 19 // thread.
20 class JniPairingSecretFetcher { 20 class JniPairingSecretFetcher {
21 public: 21 public:
22 JniPairingSecretFetcher(ChromotingJniRuntime* runtime, 22 JniPairingSecretFetcher(base::WeakPtr<JniClient> client,
23 base::WeakPtr<JniClient> client, 23 const std::string& host_id);
24 const std::string& host_id);
25 virtual ~JniPairingSecretFetcher(); 24 virtual ~JniPairingSecretFetcher();
26 25
27 // Notifies the user interface that the user needs to enter a PIN. The current 26 // Notifies the user interface that the user needs to enter a PIN. The current
28 // authentication attempt is put on hold until |callback| is invoked. 27 // authentication attempt is put on hold until |callback| is invoked.
29 void FetchSecret(bool pairable, 28 void FetchSecret(bool pairable,
30 const protocol::SecretFetchedCallback& callback); 29 const protocol::SecretFetchedCallback& callback);
31 30
32 // Provides the user's PIN and resumes the host authentication attempt. Call 31 // Provides the user's PIN and resumes the host authentication attempt. Call
33 // once the user has finished entering this PIN into the UI, but only after 32 // once the user has finished entering this PIN into the UI, but only after
34 // the UI has been asked to provide a PIN (via FetchSecret()). 33 // the UI has been asked to provide a PIN (via FetchSecret()).
35 void ProvideSecret(const std::string& pin); 34 void ProvideSecret(const std::string& pin);
36 35
37 // Get weak pointer to be used on the network thread. 36 // Get weak pointer to be used on the network thread.
38 base::WeakPtr<JniPairingSecretFetcher> GetWeakPtr(); 37 base::WeakPtr<JniPairingSecretFetcher> GetWeakPtr();
39 38
40 private: 39 private:
41 static void FetchSecretOnUiThread(base::WeakPtr<JniClient> client, 40 static void FetchSecretOnUiThread(base::WeakPtr<JniClient> client,
42 const std::string& host_id, 41 const std::string& host_id,
43 bool pairable); 42 bool pairable);
44 43
45 ChromotingJniRuntime* jni_runtime_; 44 ChromotingClientRuntime* runtime_;
46 base::WeakPtr<JniClient> jni_client_; 45 base::WeakPtr<JniClient> jni_client_;
47 46
48 std::string host_id_; 47 std::string host_id_;
49 48
50 // Pass this the user's PIN once we have it. To be assigned and accessed on 49 // Pass this the user's PIN once we have it. To be assigned and accessed on
51 // the UI thread, but must be posted to the network thread to call it. 50 // the UI thread, but must be posted to the network thread to call it.
52 protocol::SecretFetchedCallback callback_; 51 protocol::SecretFetchedCallback callback_;
53 52
54 base::WeakPtr<JniPairingSecretFetcher> weak_ptr_; 53 base::WeakPtr<JniPairingSecretFetcher> weak_ptr_;
55 base::WeakPtrFactory<JniPairingSecretFetcher> weak_factory_; 54 base::WeakPtrFactory<JniPairingSecretFetcher> weak_factory_;
56 55
57 DISALLOW_COPY_AND_ASSIGN(JniPairingSecretFetcher); 56 DISALLOW_COPY_AND_ASSIGN(JniPairingSecretFetcher);
58 }; 57 };
59 58
60 } // namespace remoting 59 } // namespace remoting
61 60
62 #endif // REMOTING_CLIENT_JNI_JNI_PAIRING_SECRET_FETCHER_H_ 61 #endif // REMOTING_CLIENT_JNI_JNI_PAIRING_SECRET_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698