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 #include "remoting/host/it2me/it2me_native_messaging_host.h" | 5 #include "remoting/host/it2me/it2me_native_messaging_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 {kDisconnecting, "DISCONNECTING"}, | 37 {kDisconnecting, "DISCONNECTING"}, |
38 {kError, "ERROR"}, | 38 {kError, "ERROR"}, |
39 {kInvalidDomainError, "INVALID_DOMAIN_ERROR"}, | 39 {kInvalidDomainError, "INVALID_DOMAIN_ERROR"}, |
40 }; | 40 }; |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 It2MeNativeMessagingHost::It2MeNativeMessagingHost( | 44 It2MeNativeMessagingHost::It2MeNativeMessagingHost( |
45 scoped_ptr<ChromotingHostContext> context, | 45 scoped_ptr<ChromotingHostContext> context, |
46 scoped_ptr<It2MeHostFactory> factory) | 46 scoped_ptr<It2MeHostFactory> factory) |
47 : client_(NULL), | 47 : client_(nullptr), |
48 host_context_(context.Pass()), | 48 host_context_(context.Pass()), |
49 factory_(factory.Pass()), | 49 factory_(factory.Pass()), |
50 weak_factory_(this) { | 50 weak_factory_(this) { |
51 weak_ptr_ = weak_factory_.GetWeakPtr(); | 51 weak_ptr_ = weak_factory_.GetWeakPtr(); |
52 | 52 |
53 // Ensures runtime specific CPU features are initialized. | 53 // Ensures runtime specific CPU features are initialized. |
54 media::InitializeCPUSpecificMediaFeatures(); | 54 media::InitializeCPUSpecificMediaFeatures(); |
55 | 55 |
56 const ServiceUrls* service_urls = ServiceUrls::GetInstance(); | 56 const ServiceUrls* service_urls = ServiceUrls::GetInstance(); |
57 const bool xmpp_server_valid = | 57 const bool xmpp_server_valid = |
58 net::ParseHostAndPort(service_urls->xmpp_server_address(), | 58 net::ParseHostAndPort(service_urls->xmpp_server_address(), |
59 &xmpp_server_config_.host, | 59 &xmpp_server_config_.host, |
60 &xmpp_server_config_.port); | 60 &xmpp_server_config_.port); |
61 DCHECK(xmpp_server_valid); | 61 DCHECK(xmpp_server_valid); |
62 | 62 |
63 xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls(); | 63 xmpp_server_config_.use_tls = service_urls->xmpp_server_use_tls(); |
64 directory_bot_jid_ = service_urls->directory_bot_jid(); | 64 directory_bot_jid_ = service_urls->directory_bot_jid(); |
65 } | 65 } |
66 | 66 |
67 It2MeNativeMessagingHost::~It2MeNativeMessagingHost() { | 67 It2MeNativeMessagingHost::~It2MeNativeMessagingHost() { |
68 DCHECK(task_runner()->BelongsToCurrentThread()); | 68 DCHECK(task_runner()->BelongsToCurrentThread()); |
69 | 69 |
70 if (it2me_host_.get()) { | 70 if (it2me_host_.get()) { |
71 it2me_host_->Disconnect(); | 71 it2me_host_->Disconnect(); |
72 it2me_host_ = NULL; | 72 it2me_host_ = nullptr; |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 void It2MeNativeMessagingHost::OnMessage(const std::string& message) { | 76 void It2MeNativeMessagingHost::OnMessage(const std::string& message) { |
77 DCHECK(task_runner()->BelongsToCurrentThread()); | 77 DCHECK(task_runner()->BelongsToCurrentThread()); |
78 | 78 |
79 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue()); | 79 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue()); |
80 scoped_ptr<base::Value> message_value(base::JSONReader::Read(message)); | 80 scoped_ptr<base::Value> message_value(base::JSONReader::Read(message)); |
81 if (!message_value->IsType(base::Value::TYPE_DICTIONARY)) { | 81 if (!message_value->IsType(base::Value::TYPE_DICTIONARY)) { |
82 LOG(ERROR) << "Received a message that's not a dictionary."; | 82 LOG(ERROR) << "Received a message that's not a dictionary."; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 SendMessageToClient(response.Pass()); | 212 SendMessageToClient(response.Pass()); |
213 } | 213 } |
214 | 214 |
215 void It2MeNativeMessagingHost::ProcessDisconnect( | 215 void It2MeNativeMessagingHost::ProcessDisconnect( |
216 const base::DictionaryValue& message, | 216 const base::DictionaryValue& message, |
217 scoped_ptr<base::DictionaryValue> response) { | 217 scoped_ptr<base::DictionaryValue> response) { |
218 DCHECK(task_runner()->BelongsToCurrentThread()); | 218 DCHECK(task_runner()->BelongsToCurrentThread()); |
219 | 219 |
220 if (it2me_host_.get()) { | 220 if (it2me_host_.get()) { |
221 it2me_host_->Disconnect(); | 221 it2me_host_->Disconnect(); |
222 it2me_host_ = NULL; | 222 it2me_host_ = nullptr; |
223 } | 223 } |
224 SendMessageToClient(response.Pass()); | 224 SendMessageToClient(response.Pass()); |
225 } | 225 } |
226 | 226 |
227 void It2MeNativeMessagingHost::SendErrorAndExit( | 227 void It2MeNativeMessagingHost::SendErrorAndExit( |
228 scoped_ptr<base::DictionaryValue> response, | 228 scoped_ptr<base::DictionaryValue> response, |
229 const std::string& description) const { | 229 const std::string& description) const { |
230 DCHECK(task_runner()->BelongsToCurrentThread()); | 230 DCHECK(task_runner()->BelongsToCurrentThread()); |
231 | 231 |
232 LOG(ERROR) << description; | 232 LOG(ERROR) << description; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 } | 306 } |
307 | 307 |
308 /* static */ | 308 /* static */ |
309 std::string It2MeNativeMessagingHost::HostStateToString( | 309 std::string It2MeNativeMessagingHost::HostStateToString( |
310 It2MeHostState host_state) { | 310 It2MeHostState host_state) { |
311 return ValueToName(kIt2MeHostStates, host_state); | 311 return ValueToName(kIt2MeHostStates, host_state); |
312 } | 312 } |
313 | 313 |
314 } // namespace remoting | 314 } // namespace remoting |
315 | 315 |
OLD | NEW |