| 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 #ifndef REMOTING_JINGLE_GLUE_JINGLE_INFO_REQUEST_H_ | 5 #ifndef REMOTING_JINGLE_GLUE_JINGLE_INFO_REQUEST_H_ |
| 6 #define REMOTING_JINGLE_GLUE_JINGLE_INFO_REQUEST_H_ | 6 #define REMOTING_JINGLE_GLUE_JINGLE_INFO_REQUEST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "remoting/jingle_glue/iq_sender.h" |
| 15 #include "third_party/libjingle/source/talk/base/sigslot.h" | 16 #include "third_party/libjingle/source/talk/base/sigslot.h" |
| 16 | 17 |
| 17 class Task; | |
| 18 | |
| 19 namespace buzz { | 18 namespace buzz { |
| 20 class XmlElement; | 19 class XmlElement; |
| 21 } // namespace buzz | 20 } // namespace buzz |
| 22 | 21 |
| 23 namespace talk_base { | 22 namespace talk_base { |
| 24 class SocketAddress; | 23 class SocketAddress; |
| 25 } // namespace talk_base | 24 } // namespace talk_base |
| 26 | 25 |
| 27 namespace remoting { | 26 namespace remoting { |
| 28 | 27 |
| 29 class IqRequest; | 28 class SignalStrategy; |
| 30 | 29 |
| 31 // JingleInfoRequest handles requesting STUN/Relay infromation from | 30 // JingleInfoRequest handles requesting STUN/Relay information from |
| 32 // the Google Talk network. The query is made when Send() is | 31 // the Google Talk network. The query is made when Send() is |
| 33 // called. The callback given to Send() is called when response to the | 32 // called. The callback given to Send() is called when response to the |
| 34 // request is received. | 33 // request is received. |
| 35 // | 34 // |
| 36 // This class is not threadsafe and should be used on the same thread it is | 35 // This class is not threadsafe and should be used on the same thread it is |
| 37 // created on. | 36 // created on. |
| 38 // | 37 // |
| 39 // TODO(ajwong): Add support for a timeout. | 38 // TODO(ajwong): Add support for a timeout. |
| 40 class JingleInfoRequest : public sigslot::has_slots<> { | 39 class JingleInfoRequest : public sigslot::has_slots<> { |
| 41 public: | 40 public: |
| 42 // Callback to receive the Jingle configuration settings. The argumetns are | 41 // Callback to receive the Jingle configuration settings. The arguments are |
| 43 // passed by pointer so the receive may call swap on them. The receiver does | 42 // passed by pointer so the receive may call swap on them. The receiver does |
| 44 // NOT own the arguments, which are guaranteed only to be alive for the | 43 // NOT own the arguments, which are guaranteed only to be alive for the |
| 45 // duration of the callback. | 44 // duration of the callback. |
| 46 typedef base::Callback<void ( | 45 typedef base::Callback<void ( |
| 47 const std::string&, const std::vector<std::string>&, | 46 const std::string&, const std::vector<std::string>&, |
| 48 const std::vector<talk_base::SocketAddress>&)> OnJingleInfoCallback; | 47 const std::vector<talk_base::SocketAddress>&)> OnJingleInfoCallback; |
| 49 | 48 |
| 50 explicit JingleInfoRequest(IqRequest* request); | 49 explicit JingleInfoRequest(SignalStrategy* signal_strategy); |
| 51 virtual ~JingleInfoRequest(); | 50 virtual ~JingleInfoRequest(); |
| 52 | 51 |
| 53 void Send(const OnJingleInfoCallback& callback); | 52 void Send(const OnJingleInfoCallback& callback); |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 struct PendingDnsRequest; | 55 struct PendingDnsRequest; |
| 57 | 56 |
| 58 void OnResponse(const buzz::XmlElement* stanza); | 57 void OnResponse(const buzz::XmlElement* stanza); |
| 59 | 58 |
| 59 IqSender iq_sender_; |
| 60 scoped_ptr<IqRequest> request_; | 60 scoped_ptr<IqRequest> request_; |
| 61 OnJingleInfoCallback on_jingle_info_cb_; | 61 OnJingleInfoCallback on_jingle_info_cb_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(JingleInfoRequest); | 63 DISALLOW_COPY_AND_ASSIGN(JingleInfoRequest); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 } // namespace remoting | 66 } // namespace remoting |
| 67 | 67 |
| 68 #endif // REMOTING_JINGLE_GLUE_JINGLE_INFO_REQUEST_H_ | 68 #endif // REMOTING_JINGLE_GLUE_JINGLE_INFO_REQUEST_H_ |
| OLD | NEW |