| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/common/net/notifier/communicator/xmpp_socket_adapter.h" | 5 #include "chrome/common/net/notifier/communicator/xmpp_socket_adapter.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "chrome/common/net/notifier/base/ssl_adapter.h" | 11 #include "chrome/common/net/notifier/base/ssl_adapter.h" |
| 12 #include "chrome/common/net/notifier/communicator/product_info.h" | 12 #include "chrome/common/net/notifier/communicator/product_info.h" |
| 13 #include "talk/base/byteorder.h" | 13 #include "talk/base/byteorder.h" |
| 14 #include "talk/base/common.h" | 14 #include "talk/base/common.h" |
| 15 #include "talk/base/firewallsocketserver.h" | 15 #include "talk/base/firewallsocketserver.h" |
| 16 #include "talk/base/logging.h" | 16 #include "talk/base/logging.h" |
| 17 #include "talk/base/socketadapters.h" | 17 #include "talk/base/socketadapters.h" |
| 18 #include "talk/base/ssladapter.h" |
| 18 #include "talk/base/thread.h" | 19 #include "talk/base/thread.h" |
| 19 #include "talk/xmpp/xmppengine.h" | 20 #include "talk/xmpp/xmppengine.h" |
| 20 | 21 |
| 21 namespace notifier { | 22 namespace notifier { |
| 22 | 23 |
| 23 XmppSocketAdapter::XmppSocketAdapter(const buzz::XmppClientSettings& xcs, | 24 XmppSocketAdapter::XmppSocketAdapter(const buzz::XmppClientSettings& xcs, |
| 24 bool allow_unverified_certs) | 25 bool allow_unverified_certs) |
| 25 : state_(STATE_CLOSED), | 26 : state_(STATE_CLOSED), |
| 26 error_(ERROR_NONE), | 27 error_(ERROR_NONE), |
| 27 wsa_error_(0), | 28 wsa_error_(0), |
| 28 socket_(NULL), | 29 socket_(NULL), |
| 29 protocol_(xcs.protocol()), | 30 protocol_(xcs.protocol()), |
| 30 firewall_(false), | 31 firewall_(false), |
| 31 write_buffer_(NULL), | 32 write_buffer_(NULL), |
| 32 write_buffer_length_(0), | 33 write_buffer_length_(0), |
| 33 write_buffer_capacity_(0), | 34 write_buffer_capacity_(0), |
| 34 allow_unverified_certs_(allow_unverified_certs) { | 35 allow_unverified_certs_(allow_unverified_certs) { |
| 35 proxy_.type = xcs.proxy(); | 36 proxy_.type = xcs.proxy(); |
| 36 proxy_.address.SetIP(xcs.proxy_host(), false); | 37 proxy_.address.SetIP(xcs.proxy_host()); |
| 37 proxy_.address.SetPort(xcs.proxy_port()); | 38 proxy_.address.SetPort(xcs.proxy_port()); |
| 38 proxy_.username = xcs.proxy_user(); | 39 proxy_.username = xcs.proxy_user(); |
| 39 proxy_.password = xcs.proxy_pass(); | 40 proxy_.password = xcs.proxy_pass(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 XmppSocketAdapter::~XmppSocketAdapter() { | 43 XmppSocketAdapter::~XmppSocketAdapter() { |
| 43 FreeState(); | 44 FreeState(); |
| 44 | 45 |
| 45 // Clean up any previous socket - cannot delete socket on close because close | 46 // Clean up any previous socket - cannot delete socket on close because close |
| 46 // happens during the child socket's stack callback. | 47 // happens during the child socket's stack callback. |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 int wsa_error = 0; | 420 int wsa_error = 0; |
| 420 FlushWriteQueue(&error, &wsa_error); | 421 FlushWriteQueue(&error, &wsa_error); |
| 421 if (error != ERROR_NONE) { | 422 if (error != ERROR_NONE) { |
| 422 Close(); | 423 Close(); |
| 423 return false; | 424 return false; |
| 424 } | 425 } |
| 425 return true; | 426 return true; |
| 426 } | 427 } |
| 427 | 428 |
| 428 } // namespace notifier | 429 } // namespace notifier |
| OLD | NEW |