| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "net/url_request/url_request_context_getter.h" |
| 15 #include "talk/base/sigslot.h" | 17 #include "talk/base/sigslot.h" |
| 16 #include "talk/xmpp/xmppengine.h" | 18 #include "talk/xmpp/xmppengine.h" |
| 17 #include "testing/gtest/include/gtest/gtest_prod.h" | 19 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 18 | 20 |
| 19 namespace buzz { | 21 namespace buzz { |
| 20 class PreXmppAuth; | 22 class PreXmppAuth; |
| 21 class XmlElement; | 23 class XmlElement; |
| 22 class XmppClientSettings; | 24 class XmppClientSettings; |
| 23 } // namespace | 25 } // namespace |
| 24 | 26 |
| 25 namespace net { | |
| 26 class CertVerifier; | |
| 27 } // namespace | |
| 28 | |
| 29 namespace talk_base { | 27 namespace talk_base { |
| 30 class Task; | 28 class Task; |
| 31 } // namespace | 29 } // namespace |
| 32 | 30 |
| 33 namespace notifier { | 31 namespace notifier { |
| 34 | 32 |
| 35 class TaskPump; | 33 class TaskPump; |
| 36 class WeakXmppClient; | 34 class WeakXmppClient; |
| 37 | 35 |
| 38 class XmppConnection : public sigslot::has_slots<> { | 36 class XmppConnection : public sigslot::has_slots<> { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 62 virtual void OnError(buzz::XmppEngine::Error error, int subcode, | 60 virtual void OnError(buzz::XmppEngine::Error error, int subcode, |
| 63 const buzz::XmlElement* stream_error) = 0; | 61 const buzz::XmlElement* stream_error) = 0; |
| 64 }; | 62 }; |
| 65 | 63 |
| 66 // Does not take ownership of |cert_verifier|, which may not be NULL. | 64 // Does not take ownership of |cert_verifier|, which may not be NULL. |
| 67 // Does not take ownership of |delegate|, which may not be NULL. | 65 // Does not take ownership of |delegate|, which may not be NULL. |
| 68 // Takes ownership of |pre_xmpp_auth|, which may be NULL. | 66 // Takes ownership of |pre_xmpp_auth|, which may be NULL. |
| 69 // | 67 // |
| 70 // TODO(akalin): Avoid the need for |pre_xmpp_auth|. | 68 // TODO(akalin): Avoid the need for |pre_xmpp_auth|. |
| 71 XmppConnection(const buzz::XmppClientSettings& xmpp_client_settings, | 69 XmppConnection(const buzz::XmppClientSettings& xmpp_client_settings, |
| 72 net::CertVerifier* cert_verifier, | 70 const scoped_refptr<net::URLRequestContextGetter>& |
| 71 request_context_getter, |
| 73 Delegate* delegate, buzz::PreXmppAuth* pre_xmpp_auth); | 72 Delegate* delegate, buzz::PreXmppAuth* pre_xmpp_auth); |
| 74 | 73 |
| 75 // Invalidates any weak pointers passed to the delegate by | 74 // Invalidates any weak pointers passed to the delegate by |
| 76 // OnConnect(), but does not trigger a call to the delegate's | 75 // OnConnect(), but does not trigger a call to the delegate's |
| 77 // OnError() function. | 76 // OnError() function. |
| 78 ~XmppConnection(); | 77 ~XmppConnection(); |
| 79 | 78 |
| 80 private: | 79 private: |
| 81 void OnStateChange(buzz::XmppEngine::State state); | 80 void OnStateChange(buzz::XmppEngine::State state); |
| 82 void OnInputLog(const char* data, int len); | 81 void OnInputLog(const char* data, int len); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 94 FRIEND_TEST(XmppConnectionTest, Connect); | 93 FRIEND_TEST(XmppConnectionTest, Connect); |
| 95 FRIEND_TEST(XmppConnectionTest, MultipleConnect); | 94 FRIEND_TEST(XmppConnectionTest, MultipleConnect); |
| 96 FRIEND_TEST(XmppConnectionTest, ConnectThenError); | 95 FRIEND_TEST(XmppConnectionTest, ConnectThenError); |
| 97 | 96 |
| 98 DISALLOW_COPY_AND_ASSIGN(XmppConnection); | 97 DISALLOW_COPY_AND_ASSIGN(XmppConnection); |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 } // namespace notifier | 100 } // namespace notifier |
| 102 | 101 |
| 103 #endif // JINGLE_NOTIFIER_BASE_XMPP_CONNECTION_H_ | 102 #endif // JINGLE_NOTIFIER_BASE_XMPP_CONNECTION_H_ |
| OLD | NEW |