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

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

Issue 2745583008: Refactoring out the chromoting jni runtime class in favor of chromoting client runtime. (Closed)
Patch Set: 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 #include "remoting/client/jni/jni_pairing_secret_fetcher.h" 5 #include "remoting/client/jni/jni_pairing_secret_fetcher.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "remoting/client/jni/chromoting_jni_runtime.h" 8 #include "remoting/client/chromoting_client_runtime.h"
9 #include "remoting/client/jni/jni_client.h" 9 #include "remoting/client/jni/jni_client.h"
10 10
11 namespace remoting { 11 namespace remoting {
12 12
13 JniPairingSecretFetcher::JniPairingSecretFetcher(ChromotingJniRuntime* runtime, 13 JniPairingSecretFetcher::JniPairingSecretFetcher(
14 base::WeakPtr<JniClient> client, 14 base::WeakPtr<JniClient> client,
15 const std::string& host_id) : 15 const std::string& host_id)
16 jni_runtime_(runtime), 16 : jni_client_(client), host_id_(host_id), weak_factory_(this) {
17 jni_client_(client), 17 runtime_ = ChromotingClientRuntime::GetInstance();
18 host_id_(host_id),
19 weak_factory_(this) {
20 weak_ptr_ = weak_factory_.GetWeakPtr(); 18 weak_ptr_ = weak_factory_.GetWeakPtr();
21 } 19 }
22 20
23 JniPairingSecretFetcher::~JniPairingSecretFetcher() { 21 JniPairingSecretFetcher::~JniPairingSecretFetcher() {
24 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); 22 DCHECK(runtime_->network_task_runner()->BelongsToCurrentThread());
25 } 23 }
26 24
27 void JniPairingSecretFetcher::FetchSecret( 25 void JniPairingSecretFetcher::FetchSecret(
28 bool pairable, 26 bool pairable,
29 const protocol::SecretFetchedCallback& callback) { 27 const protocol::SecretFetchedCallback& callback) {
30 DCHECK (jni_runtime_->network_task_runner()->BelongsToCurrentThread()); 28 DCHECK(runtime_->network_task_runner()->BelongsToCurrentThread());
31 29
32 callback_ = callback; 30 callback_ = callback;
33 jni_runtime_->ui_task_runner()->PostTask( 31 runtime_->ui_task_runner()->PostTask(
34 FROM_HERE, 32 FROM_HERE, base::Bind(&JniPairingSecretFetcher::FetchSecretOnUiThread,
35 base::Bind(&JniPairingSecretFetcher::FetchSecretOnUiThread, jni_client_, 33 jni_client_, host_id_, pairable));
36 host_id_, pairable));
37 } 34 }
38 35
39 void JniPairingSecretFetcher::ProvideSecret(const std::string& pin) { 36 void JniPairingSecretFetcher::ProvideSecret(const std::string& pin) {
40 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); 37 DCHECK(runtime_->network_task_runner()->BelongsToCurrentThread());
41 DCHECK(!callback_.is_null()); 38 DCHECK(!callback_.is_null());
42 39
43 callback_.Run(pin); 40 callback_.Run(pin);
44 } 41 }
45 42
46 base::WeakPtr<JniPairingSecretFetcher> JniPairingSecretFetcher::GetWeakPtr() { 43 base::WeakPtr<JniPairingSecretFetcher> JniPairingSecretFetcher::GetWeakPtr() {
47 return weak_ptr_; 44 return weak_ptr_;
48 } 45 }
49 46
50 // static 47 // static
51 void JniPairingSecretFetcher::FetchSecretOnUiThread( 48 void JniPairingSecretFetcher::FetchSecretOnUiThread(
52 base::WeakPtr<JniClient> client, 49 base::WeakPtr<JniClient> client,
53 const std::string& host_id, 50 const std::string& host_id,
54 bool pairable) { 51 bool pairable) {
55 if (!client) { 52 if (!client) {
56 return; 53 return;
57 } 54 }
58 55
59 // Delete pairing credentials if they exist. 56 // Delete pairing credentials if they exist.
60 client->CommitPairingCredentials(host_id, "", ""); 57 client->CommitPairingCredentials(host_id, "", "");
61 58
62 client->DisplayAuthenticationPrompt(pairable); 59 client->DisplayAuthenticationPrompt(pairable);
63 } 60 }
64 61
65 } // namespace remoting 62 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698