| 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 // A class that manages a connection to an XMPP server. | 5 // A class that manages a connection to an XMPP server. |
| 6 | 6 |
| 7 #ifndef JINGLE_NOTIFIER_BASE_XMPP_CONNECTION_H_ | 7 #ifndef JINGLE_NOTIFIER_BASE_XMPP_CONNECTION_H_ |
| 8 #define JINGLE_NOTIFIER_BASE_XMPP_CONNECTION_H_ | 8 #define JINGLE_NOTIFIER_BASE_XMPP_CONNECTION_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/non_thread_safe.h" | 12 #include "base/non_thread_safe.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/weak_ptr.h" | 14 #include "base/weak_ptr.h" |
| 15 #include "talk/base/sigslot.h" | 15 #include "talk/base/sigslot.h" |
| 16 #include "talk/xmpp/xmppengine.h" | 16 #include "talk/xmpp/xmppengine.h" |
| 17 #include "testing/gtest/include/gtest/gtest_prod.h" | 17 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 18 | 18 |
| 19 namespace buzz { | 19 namespace buzz { |
| 20 class PreXmppAuth; | 20 class PreXmppAuth; |
| 21 class XmlElement; | 21 class XmlElement; |
| 22 class XmppClientSettings; | 22 class XmppClientSettings; |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 namespace net { |
| 26 class CertVerifier; |
| 27 } // namespace |
| 28 |
| 25 namespace talk_base { | 29 namespace talk_base { |
| 26 class Task; | 30 class Task; |
| 27 } // namespace | 31 } // namespace |
| 28 | 32 |
| 29 namespace notifier { | 33 namespace notifier { |
| 30 | 34 |
| 31 class TaskPump; | 35 class TaskPump; |
| 32 class WeakXmppClient; | 36 class WeakXmppClient; |
| 33 | 37 |
| 34 class XmppConnection : public sigslot::has_slots<> { | 38 class XmppConnection : public sigslot::has_slots<> { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 52 // is non-NULL iff |error| == ERROR_STREAM. |stream_error| is | 56 // is non-NULL iff |error| == ERROR_STREAM. |stream_error| is |
| 53 // valid only for the lifetime of this function. | 57 // valid only for the lifetime of this function. |
| 54 // | 58 // |
| 55 // Ideally, |error| would be set to something that is not | 59 // Ideally, |error| would be set to something that is not |
| 56 // ERROR_NONE, but due to inconsistent error-handling this doesn't | 60 // ERROR_NONE, but due to inconsistent error-handling this doesn't |
| 57 // always happen. | 61 // always happen. |
| 58 virtual void OnError(buzz::XmppEngine::Error error, int subcode, | 62 virtual void OnError(buzz::XmppEngine::Error error, int subcode, |
| 59 const buzz::XmlElement* stream_error) = 0; | 63 const buzz::XmlElement* stream_error) = 0; |
| 60 }; | 64 }; |
| 61 | 65 |
| 66 // Does not take ownership of |cert_verifier|, which may not be NULL. |
| 62 // Does not take ownership of |delegate|, which may not be NULL. | 67 // Does not take ownership of |delegate|, which may not be NULL. |
| 63 // Takes ownership of |pre_xmpp_auth|, which may be NULL. | 68 // Takes ownership of |pre_xmpp_auth|, which may be NULL. |
| 64 // | 69 // |
| 65 // TODO(akalin): Avoid the need for |pre_xmpp_auth|. | 70 // TODO(akalin): Avoid the need for |pre_xmpp_auth|. |
| 66 XmppConnection(const buzz::XmppClientSettings& xmpp_client_settings, | 71 XmppConnection(const buzz::XmppClientSettings& xmpp_client_settings, |
| 72 net::CertVerifier* cert_verifier, |
| 67 Delegate* delegate, buzz::PreXmppAuth* pre_xmpp_auth); | 73 Delegate* delegate, buzz::PreXmppAuth* pre_xmpp_auth); |
| 68 | 74 |
| 69 // Invalidates any weak pointers passed to the delegate by | 75 // Invalidates any weak pointers passed to the delegate by |
| 70 // OnConnect(), but does not trigger a call to the delegate's | 76 // OnConnect(), but does not trigger a call to the delegate's |
| 71 // OnError() function. | 77 // OnError() function. |
| 72 ~XmppConnection(); | 78 ~XmppConnection(); |
| 73 | 79 |
| 74 private: | 80 private: |
| 75 void OnStateChange(buzz::XmppEngine::State state); | 81 void OnStateChange(buzz::XmppEngine::State state); |
| 76 void OnInputLog(const char* data, int len); | 82 void OnInputLog(const char* data, int len); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 88 FRIEND_TEST(XmppConnectionTest, Connect); | 94 FRIEND_TEST(XmppConnectionTest, Connect); |
| 89 FRIEND_TEST(XmppConnectionTest, MultipleConnect); | 95 FRIEND_TEST(XmppConnectionTest, MultipleConnect); |
| 90 FRIEND_TEST(XmppConnectionTest, ConnectThenError); | 96 FRIEND_TEST(XmppConnectionTest, ConnectThenError); |
| 91 | 97 |
| 92 DISALLOW_COPY_AND_ASSIGN(XmppConnection); | 98 DISALLOW_COPY_AND_ASSIGN(XmppConnection); |
| 93 }; | 99 }; |
| 94 | 100 |
| 95 } // namespace notifier | 101 } // namespace notifier |
| 96 | 102 |
| 97 #endif // JINGLE_NOTIFIER_BASE_XMPP_CONNECTION_H_ | 103 #endif // JINGLE_NOTIFIER_BASE_XMPP_CONNECTION_H_ |
| OLD | NEW |