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