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

Side by Side Diff: remoting/host/it2me/it2me_host.cc

Issue 2847853003: Remove policy watching from It2MeHost. (Closed)
Patch Set: Fix unit tests Created 3 years, 7 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 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 #include "remoting/host/it2me/it2me_host.h" 5 #include "remoting/host/it2me/it2me_host.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 10 matching lines...) Expand all
21 #include "remoting/base/logging.h" 21 #include "remoting/base/logging.h"
22 #include "remoting/base/rsa_key_pair.h" 22 #include "remoting/base/rsa_key_pair.h"
23 #include "remoting/base/service_urls.h" 23 #include "remoting/base/service_urls.h"
24 #include "remoting/host/chromoting_host.h" 24 #include "remoting/host/chromoting_host.h"
25 #include "remoting/host/chromoting_host_context.h" 25 #include "remoting/host/chromoting_host_context.h"
26 #include "remoting/host/host_event_logger.h" 26 #include "remoting/host/host_event_logger.h"
27 #include "remoting/host/host_secret.h" 27 #include "remoting/host/host_secret.h"
28 #include "remoting/host/host_status_logger.h" 28 #include "remoting/host/host_status_logger.h"
29 #include "remoting/host/it2me/it2me_confirmation_dialog.h" 29 #include "remoting/host/it2me/it2me_confirmation_dialog.h"
30 #include "remoting/host/it2me_desktop_environment.h" 30 #include "remoting/host/it2me_desktop_environment.h"
31 #include "remoting/host/policy_watcher.h"
32 #include "remoting/host/register_support_host_request.h" 31 #include "remoting/host/register_support_host_request.h"
33 #include "remoting/protocol/auth_util.h" 32 #include "remoting/protocol/auth_util.h"
34 #include "remoting/protocol/chromium_port_allocator_factory.h" 33 #include "remoting/protocol/chromium_port_allocator_factory.h"
35 #include "remoting/protocol/ice_transport.h" 34 #include "remoting/protocol/ice_transport.h"
36 #include "remoting/protocol/it2me_host_authenticator_factory.h" 35 #include "remoting/protocol/it2me_host_authenticator_factory.h"
37 #include "remoting/protocol/jingle_session_manager.h" 36 #include "remoting/protocol/jingle_session_manager.h"
38 #include "remoting/protocol/network_settings.h" 37 #include "remoting/protocol/network_settings.h"
39 #include "remoting/protocol/transport_context.h" 38 #include "remoting/protocol/transport_context.h"
40 #include "remoting/protocol/validating_authenticator.h" 39 #include "remoting/protocol/validating_authenticator.h"
41 #include "remoting/signaling/jid_util.h" 40 #include "remoting/signaling/jid_util.h"
42 #include "remoting/signaling/server_log_entry.h" 41 #include "remoting/signaling/server_log_entry.h"
43 42
44 namespace remoting { 43 namespace remoting {
45 44
46 namespace { 45 namespace {
47 46
48 // This is used for tagging system event logs. 47 // This is used for tagging system event logs.
49 const char kApplicationName[] = "chromoting"; 48 const char kApplicationName[] = "chromoting";
50 const int kMaxLoginAttempts = 5; 49 const int kMaxLoginAttempts = 5;
51 50
52 using protocol::ValidatingAuthenticator; 51 using protocol::ValidatingAuthenticator;
53 typedef ValidatingAuthenticator::Result ValidationResult; 52 typedef ValidatingAuthenticator::Result ValidationResult;
54 typedef ValidatingAuthenticator::ValidationCallback ValidationCallback; 53 typedef ValidatingAuthenticator::ValidationCallback ValidationCallback;
55 typedef ValidatingAuthenticator::ResultCallback ValidationResultCallback; 54 typedef ValidatingAuthenticator::ResultCallback ValidationResultCallback;
56 55
57 } // namespace 56 } // namespace
58 57
59 It2MeHost::It2MeHost( 58 It2MeHost::It2MeHost(
60 std::unique_ptr<ChromotingHostContext> host_context, 59 std::unique_ptr<ChromotingHostContext> host_context,
61 std::unique_ptr<PolicyWatcher> policy_watcher,
62 std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory, 60 std::unique_ptr<It2MeConfirmationDialogFactory> dialog_factory,
63 base::WeakPtr<It2MeHost::Observer> observer, 61 base::WeakPtr<It2MeHost::Observer> observer,
64 std::unique_ptr<SignalStrategy> signal_strategy, 62 std::unique_ptr<SignalStrategy> signal_strategy,
65 const std::string& username, 63 const std::string& username,
66 const std::string& directory_bot_jid) 64 const std::string& directory_bot_jid)
67 : host_context_(std::move(host_context)), 65 : host_context_(std::move(host_context)),
68 observer_(observer), 66 observer_(observer),
69 signal_strategy_(std::move(signal_strategy)), 67 signal_strategy_(std::move(signal_strategy)),
70 username_(username), 68 username_(username),
71 directory_bot_jid_(directory_bot_jid), 69 directory_bot_jid_(directory_bot_jid),
72 policy_watcher_(std::move(policy_watcher)),
73 confirmation_dialog_factory_(std::move(dialog_factory)) { 70 confirmation_dialog_factory_(std::move(dialog_factory)) {
74 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread()); 71 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread());
75 } 72 }
76 73
77 It2MeHost::~It2MeHost() { 74 It2MeHost::~It2MeHost() {
78 // Check that resources that need to be torn down on the UI thread are gone. 75 // Check that resources that need to be torn down on the UI thread are gone.
79 DCHECK(!desktop_environment_factory_.get()); 76 DCHECK(!desktop_environment_factory_.get());
80 DCHECK(!policy_watcher_.get());
81 } 77 }
82 78
83 void It2MeHost::Connect() { 79 void It2MeHost::Connect() {
84 if (!host_context_->ui_task_runner()->BelongsToCurrentThread()) { 80 if (!host_context_->ui_task_runner()->BelongsToCurrentThread()) {
85 host_context_->ui_task_runner()->PostTask( 81 host_context_->ui_task_runner()->PostTask(
86 FROM_HERE, base::Bind(&It2MeHost::Connect, this)); 82 FROM_HERE, base::Bind(&It2MeHost::Connect, this));
87 return; 83 return;
88 } 84 }
89 85
90 desktop_environment_factory_.reset(new It2MeDesktopEnvironmentFactory( 86 desktop_environment_factory_.reset(new It2MeDesktopEnvironmentFactory(
91 host_context_->network_task_runner(), 87 host_context_->network_task_runner(),
92 host_context_->video_capture_task_runner(), 88 host_context_->video_capture_task_runner(),
93 host_context_->input_task_runner(), host_context_->ui_task_runner())); 89 host_context_->input_task_runner(), host_context_->ui_task_runner()));
94 90
95 // Start monitoring configured policies.
96 policy_watcher_->StartWatching(
97 base::Bind(&It2MeHost::OnPolicyUpdate, this),
98 base::Bind(&It2MeHost::OnPolicyError, this));
99
100 // Switch to the network thread to start the actual connection. 91 // Switch to the network thread to start the actual connection.
101 host_context_->network_task_runner()->PostTask( 92 host_context_->network_task_runner()->PostTask(
102 FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this)); 93 FROM_HERE, base::Bind(&It2MeHost::ReadPolicyAndConnect, this));
103 } 94 }
104 95
105 void It2MeHost::Disconnect() { 96 void It2MeHost::Disconnect() {
106 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread()); 97 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread());
107 host_context_->network_task_runner()->PostTask( 98 host_context_->network_task_runner()->PostTask(
108 FROM_HERE, base::Bind(&It2MeHost::DisconnectOnNetworkThread, this)); 99 FROM_HERE, base::Bind(&It2MeHost::DisconnectOnNetworkThread, this));
109 } 100 }
(...skipping 15 matching lines...) Expand all
125 host_.reset(); 116 host_.reset();
126 } 117 }
127 118
128 register_request_.reset(); 119 register_request_.reset();
129 host_status_logger_.reset(); 120 host_status_logger_.reset();
130 signal_strategy_.reset(); 121 signal_strategy_.reset();
131 122
132 // Post tasks to delete UI objects on the UI thread. 123 // Post tasks to delete UI objects on the UI thread.
133 host_context_->ui_task_runner()->DeleteSoon( 124 host_context_->ui_task_runner()->DeleteSoon(
134 FROM_HERE, desktop_environment_factory_.release()); 125 FROM_HERE, desktop_environment_factory_.release());
135 host_context_->ui_task_runner()->DeleteSoon(FROM_HERE,
136 policy_watcher_.release());
137 126
138 SetState(kDisconnected, ""); 127 SetState(kDisconnected, "");
139 } 128 }
140 129
141 void It2MeHost::RequestNatPolicy() { 130 void It2MeHost::RequestNatPolicy() {
142 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) { 131 if (!host_context_->network_task_runner()->BelongsToCurrentThread()) {
143 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread()); 132 DCHECK(host_context_->ui_task_runner()->BelongsToCurrentThread());
144 host_context_->network_task_runner()->PostTask( 133 host_context_->network_task_runner()->PostTask(
145 FROM_HERE, base::Bind(&It2MeHost::RequestNatPolicy, this)); 134 FROM_HERE, base::Bind(&It2MeHost::RequestNatPolicy, this));
146 return; 135 return;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 UpdateClientDomainListPolicy(std::move(client_domain_list_vector)); 330 UpdateClientDomainListPolicy(std::move(client_domain_list_vector));
342 } 331 }
343 332
344 policy_received_ = true; 333 policy_received_ = true;
345 334
346 if (!pending_connect_.is_null()) { 335 if (!pending_connect_.is_null()) {
347 base::ResetAndReturn(&pending_connect_).Run(); 336 base::ResetAndReturn(&pending_connect_).Run();
348 } 337 }
349 } 338 }
350 339
351 void It2MeHost::OnPolicyError() {
352 // TODO(lukasza): Report the policy error to the user. crbug.com/433009
353 NOTIMPLEMENTED();
354 }
355
356 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) { 340 void It2MeHost::UpdateNatPolicy(bool nat_traversal_enabled) {
357 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread()); 341 DCHECK(host_context_->network_task_runner()->BelongsToCurrentThread());
358 342
359 VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled; 343 VLOG(2) << "UpdateNatPolicy: " << nat_traversal_enabled;
360 344
361 // When transitioning from enabled to disabled, force disconnect any 345 // When transitioning from enabled to disabled, force disconnect any
362 // existing session. 346 // existing session.
363 if (nat_traversal_enabled_ && !nat_traversal_enabled && IsRunning()) { 347 if (nat_traversal_enabled_ && !nat_traversal_enabled && IsRunning()) {
364 DisconnectOnNetworkThread(); 348 DisconnectOnNetworkThread();
365 } 349 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 It2MeHostFactory::~It2MeHostFactory() {} 571 It2MeHostFactory::~It2MeHostFactory() {}
588 572
589 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost( 573 scoped_refptr<It2MeHost> It2MeHostFactory::CreateIt2MeHost(
590 std::unique_ptr<ChromotingHostContext> context, 574 std::unique_ptr<ChromotingHostContext> context,
591 policy::PolicyService* policy_service, 575 policy::PolicyService* policy_service,
592 base::WeakPtr<It2MeHost::Observer> observer, 576 base::WeakPtr<It2MeHost::Observer> observer,
593 std::unique_ptr<SignalStrategy> signal_strategy, 577 std::unique_ptr<SignalStrategy> signal_strategy,
594 const std::string& username, 578 const std::string& username,
595 const std::string& directory_bot_jid) { 579 const std::string& directory_bot_jid) {
596 DCHECK(context->ui_task_runner()->BelongsToCurrentThread()); 580 DCHECK(context->ui_task_runner()->BelongsToCurrentThread());
597 581 return new It2MeHost(
598 std::unique_ptr<PolicyWatcher> policy_watcher = 582 std::move(context), base::MakeUnique<It2MeConfirmationDialogFactory>(),
599 PolicyWatcher::Create(policy_service, context->file_task_runner()); 583 observer, std::move(signal_strategy), username, directory_bot_jid);
600 return new It2MeHost(std::move(context), std::move(policy_watcher),
601 base::MakeUnique<It2MeConfirmationDialogFactory>(),
602 observer, std::move(signal_strategy), username,
603 directory_bot_jid);
604 } 584 }
605 585
606 } // namespace remoting 586 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698