OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/task.h" | 15 #include "base/task.h" |
16 #include "base/weak_ptr.h" | 16 #include "base/weak_ptr.h" |
17 #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" | 17 #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" |
18 #include "chrome/browser/sync/notifier/chrome_invalidation_client.h" | 18 #include "chrome/browser/sync/notifier/chrome_invalidation_client.h" |
19 #include "chrome/browser/sync/notifier/chrome_system_resources.h" | 19 #include "chrome/browser/sync/notifier/chrome_system_resources.h" |
20 #include "chrome/browser/sync/sync_constants.h" | 20 #include "chrome/browser/sync/sync_constants.h" |
21 #include "jingle/notifier/base/xmpp_connection.h" | 21 #include "jingle/notifier/base/xmpp_connection.h" |
22 #include "jingle/notifier/listener/listen_task.h" | 22 #include "jingle/notifier/listener/listen_task.h" |
23 #include "jingle/notifier/listener/notification_constants.h" | 23 #include "jingle/notifier/listener/notification_constants.h" |
24 #include "jingle/notifier/listener/notification_defines.h" | 24 #include "jingle/notifier/listener/notification_defines.h" |
25 #include "jingle/notifier/listener/send_update_task.h" | 25 #include "jingle/notifier/listener/send_update_task.h" |
26 #include "jingle/notifier/listener/subscribe_task.h" | 26 #include "jingle/notifier/listener/subscribe_task.h" |
27 #include "jingle/notifier/listener/xml_element_util.h" | 27 #include "jingle/notifier/listener/xml_element_util.h" |
28 #include "net/base/cert_verifier.h" | |
28 #include "net/base/ssl_config_service.h" | 29 #include "net/base/ssl_config_service.h" |
29 #include "net/socket/client_socket_factory.h" | 30 #include "net/socket/client_socket_factory.h" |
30 #include "talk/base/cryptstring.h" | 31 #include "talk/base/cryptstring.h" |
31 #include "talk/base/logging.h" | 32 #include "talk/base/logging.h" |
32 #include "talk/base/sigslot.h" | 33 #include "talk/base/sigslot.h" |
33 #include "talk/base/task.h" | 34 #include "talk/base/task.h" |
34 #include "talk/xmpp/jid.h" | 35 #include "talk/xmpp/jid.h" |
35 #include "talk/xmpp/xmppclientsettings.h" | 36 #include "talk/xmpp/xmppclientsettings.h" |
36 #include "talk/xmpp/constants.h" | 37 #include "talk/xmpp/constants.h" |
37 #include "talk/xmpp/xmppengine.h" | 38 #include "talk/xmpp/xmppengine.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
59 | 60 |
60 template <class T> XmppNotificationClient(T begin, T end) { | 61 template <class T> XmppNotificationClient(T begin, T end) { |
61 for (T it = begin; it != end; ++it) { | 62 for (T it = begin; it != end; ++it) { |
62 observer_list_.AddObserver(*it); | 63 observer_list_.AddObserver(*it); |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 virtual ~XmppNotificationClient() {} | 67 virtual ~XmppNotificationClient() {} |
67 | 68 |
68 // Connect with the given XMPP settings and run until disconnected. | 69 // Connect with the given XMPP settings and run until disconnected. |
69 void Run(const buzz::XmppClientSettings& xmpp_client_settings) { | 70 void Run(const buzz::XmppClientSettings& xmpp_client_settings, |
71 net::CertVerifier* cert_verifier) { | |
70 DCHECK(!xmpp_connection_.get()); | 72 DCHECK(!xmpp_connection_.get()); |
71 xmpp_connection_.reset( | 73 xmpp_connection_.reset( |
72 new notifier::XmppConnection(xmpp_client_settings, this, NULL)); | 74 new notifier::XmppConnection(xmpp_client_settings, cert_verifier, |
75 this, NULL)); | |
73 MessageLoop::current()->Run(); | 76 MessageLoop::current()->Run(); |
74 DCHECK(!xmpp_connection_.get()); | 77 DCHECK(!xmpp_connection_.get()); |
75 } | 78 } |
76 | 79 |
77 virtual void OnConnect(base::WeakPtr<talk_base::Task> base_task) { | 80 virtual void OnConnect(base::WeakPtr<talk_base::Task> base_task) { |
78 FOR_EACH_OBSERVER(Observer, observer_list_, OnConnect(base_task)); | 81 FOR_EACH_OBSERVER(Observer, observer_list_, OnConnect(base_task)); |
79 } | 82 } |
80 | 83 |
81 virtual void OnError(buzz::XmppEngine::Error error, int subcode, | 84 virtual void OnError(buzz::XmppEngine::Error error, int subcode, |
82 const buzz::XmlElement* stream_error) { | 85 const buzz::XmlElement* stream_error) { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 insecure_crypt_string.password() = password; | 291 insecure_crypt_string.password() = password; |
289 xmpp_client_settings.set_pass( | 292 xmpp_client_settings.set_pass( |
290 talk_base::CryptString(insecure_crypt_string)); | 293 talk_base::CryptString(insecure_crypt_string)); |
291 talk_base::SocketAddress addr(server, port); | 294 talk_base::SocketAddress addr(server, port); |
292 if (!addr.ResolveIP()) { | 295 if (!addr.ResolveIP()) { |
293 LOG(ERROR) << "Could not resolve " << addr.ToString(); | 296 LOG(ERROR) << "Could not resolve " << addr.ToString(); |
294 return -1; | 297 return -1; |
295 } | 298 } |
296 xmpp_client_settings.set_server(addr); | 299 xmpp_client_settings.set_server(addr); |
297 | 300 |
301 net::CertVerifier cert_verifier; | |
302 | |
agl
2010/12/17 16:22:01
(very minor): I would remove this blank line.
| |
298 MessageLoopForIO message_loop; | 303 MessageLoopForIO message_loop; |
299 | 304 |
300 // Connect and listen. | 305 // Connect and listen. |
301 ServerNotifierDelegate server_notifier_delegate( | 306 ServerNotifierDelegate server_notifier_delegate( |
302 server_notifier_state); | 307 server_notifier_state); |
303 LegacyNotifierDelegate legacy_notifier_delegate( | 308 LegacyNotifierDelegate legacy_notifier_delegate( |
304 legacy_notifier_send_initial_update); | 309 legacy_notifier_send_initial_update); |
305 std::vector<XmppNotificationClient::Observer*> observers; | 310 std::vector<XmppNotificationClient::Observer*> observers; |
306 if (use_legacy_notifier) { | 311 if (use_legacy_notifier) { |
307 observers.push_back(&legacy_notifier_delegate); | 312 observers.push_back(&legacy_notifier_delegate); |
308 } else { | 313 } else { |
309 observers.push_back(&server_notifier_delegate); | 314 observers.push_back(&server_notifier_delegate); |
310 } | 315 } |
311 XmppNotificationClient xmpp_notification_client( | 316 XmppNotificationClient xmpp_notification_client( |
312 observers.begin(), observers.end()); | 317 observers.begin(), observers.end()); |
313 xmpp_notification_client.Run(xmpp_client_settings); | 318 xmpp_notification_client.Run(xmpp_client_settings, &cert_verifier); |
314 | 319 |
315 return 0; | 320 return 0; |
316 } | 321 } |
OLD | NEW |