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

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

Issue 2747743004: Fix crash when user disconnects It2Me host (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 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_native_messaging_host.h" 5 #include "remoting/host/it2me/it2me_native_messaging_host.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 net::ClientSocketFactory::GetDefaultFactory(), 289 net::ClientSocketFactory::GetDefaultFactory(),
290 host_context_->url_request_context_getter(), xmpp_config)); 290 host_context_->url_request_context_getter(), xmpp_config));
291 } else { 291 } else {
292 std::string local_jid; 292 std::string local_jid;
293 293
294 if (!message->GetString("localJid", &local_jid)) { 294 if (!message->GetString("localJid", &local_jid)) {
295 SendErrorAndExit(std::move(response), "'localJid' not found in request."); 295 SendErrorAndExit(std::move(response), "'localJid' not found in request.");
296 return; 296 return;
297 } 297 }
298 298
299 delegating_signal_strategy_ = new DelegatingSignalStrategy( 299 DelegatingSignalStrategy* delegating_signal_strategy =
Sergey Ulanov 2017/03/14 19:20:58 Use unique_ptr<> please: auto delegating_signal
kelvinp 2017/03/15 21:56:46 Done.
300 local_jid, host_context_->network_task_runner(), 300 new DelegatingSignalStrategy(
301 base::Bind(&It2MeNativeMessagingHost::SendOutgoingIq, 301 local_jid, host_context_->network_task_runner(),
302 weak_factory_.GetWeakPtr())); 302 base::Bind(&It2MeNativeMessagingHost::SendOutgoingIq,
303 signal_strategy.reset(delegating_signal_strategy_); 303 weak_factory_.GetWeakPtr()));
304 incoming_message_callback_ =
305 delegating_signal_strategy->MakeIncomingMessageCallback();
306 signal_strategy.reset(delegating_signal_strategy);
Sergey Ulanov 2017/03/14 19:20:58 signal_strategy = std::move(delegating_signal_stra
kelvinp 2017/03/15 21:56:46 Done.
304 } 307 }
305 308
306 std::string directory_bot_jid = service_urls->directory_bot_jid(); 309 std::string directory_bot_jid = service_urls->directory_bot_jid();
307 310
308 #if !defined(NDEBUG) 311 #if !defined(NDEBUG)
309 if (!message->GetString("directoryBotJid", &directory_bot_jid)) { 312 if (!message->GetString("directoryBotJid", &directory_bot_jid)) {
310 SendErrorAndExit(std::move(response), 313 SendErrorAndExit(std::move(response),
311 "'directoryBotJid' not found in request."); 314 "'directoryBotJid' not found in request.");
312 return; 315 return;
313 } 316 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 353
351 void It2MeNativeMessagingHost::ProcessIncomingIq( 354 void It2MeNativeMessagingHost::ProcessIncomingIq(
352 std::unique_ptr<base::DictionaryValue> message, 355 std::unique_ptr<base::DictionaryValue> message,
353 std::unique_ptr<base::DictionaryValue> response) { 356 std::unique_ptr<base::DictionaryValue> response) {
354 std::string iq; 357 std::string iq;
355 if (!message->GetString("iq", &iq)) { 358 if (!message->GetString("iq", &iq)) {
356 LOG(ERROR) << "Invalid incomingIq() data."; 359 LOG(ERROR) << "Invalid incomingIq() data.";
357 return; 360 return;
358 } 361 }
359 362
360 if (delegating_signal_strategy_) 363 incoming_message_callback_.Run(iq);
361 delegating_signal_strategy_->OnIncomingMessage(iq);
362 SendMessageToClient(std::move(response)); 364 SendMessageToClient(std::move(response));
363 }; 365 };
364 366
365 void It2MeNativeMessagingHost::SendOutgoingIq(const std::string& iq) { 367 void It2MeNativeMessagingHost::SendOutgoingIq(const std::string& iq) {
366 std::unique_ptr<base::DictionaryValue> message(new base::DictionaryValue()); 368 std::unique_ptr<base::DictionaryValue> message(new base::DictionaryValue());
367 message->SetString("iq", iq); 369 message->SetString("iq", iq);
368 message->SetString("type", "sendOutgoingIq"); 370 message->SetString("type", "sendOutgoingIq");
369 SendMessageToClient(std::move(message)); 371 SendMessageToClient(std::move(message));
370 } 372 }
371 373
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 530
529 bool It2MeNativeMessagingHost::DelegateToElevatedHost( 531 bool It2MeNativeMessagingHost::DelegateToElevatedHost(
530 std::unique_ptr<base::DictionaryValue> message) { 532 std::unique_ptr<base::DictionaryValue> message) {
531 NOTREACHED(); 533 NOTREACHED();
532 return false; 534 return false;
533 } 535 }
534 536
535 #endif // !defined(OS_WIN) 537 #endif // !defined(OS_WIN)
536 538
537 } // namespace remoting 539 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698