| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/protocol/transport_context.h" | 5 #include "remoting/protocol/transport_context.h" | 
| 6 | 6 | 
| 7 #include <utility> | 7 #include <utility> | 
| 8 | 8 | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/location.h" | 10 #include "base/location.h" | 
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" | 
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" | 
|  | 13 #include "remoting/base/url_request.h" | 
| 13 #include "remoting/protocol/port_allocator_factory.h" | 14 #include "remoting/protocol/port_allocator_factory.h" | 
| 14 #include "third_party/webrtc/base/socketaddress.h" | 15 #include "third_party/webrtc/base/socketaddress.h" | 
| 15 | 16 | 
| 16 #if !defined(OS_NACL) | 17 #if !defined(OS_NACL) | 
| 17 #include "jingle/glue/thread_wrapper.h" | 18 #include "jingle/glue/thread_wrapper.h" | 
| 18 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" | 
| 19 #include "remoting/protocol/chromium_port_allocator.h" | 20 #include "remoting/protocol/chromium_port_allocator_factory.h" | 
| 20 #endif  // !defined(OS_NACL) | 21 #endif  // !defined(OS_NACL) | 
| 21 | 22 | 
| 22 namespace remoting { | 23 namespace remoting { | 
| 23 namespace protocol { | 24 namespace protocol { | 
| 24 | 25 | 
| 25 // Get fresh STUN/Relay configuration every hour. | 26 // Get fresh STUN/Relay configuration every hour. | 
| 26 static const int kJingleInfoUpdatePeriodSeconds = 3600; | 27 static const int kJingleInfoUpdatePeriodSeconds = 3600; | 
| 27 | 28 | 
| 28 #if !defined(OS_NACL) | 29 #if !defined(OS_NACL) | 
| 29 // static | 30 // static | 
| 30 scoped_refptr<TransportContext> TransportContext::ForTests(TransportRole role) { | 31 scoped_refptr<TransportContext> TransportContext::ForTests(TransportRole role) { | 
| 31   jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 32   jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 
| 32   return new protocol::TransportContext( | 33   return new protocol::TransportContext( | 
| 33       nullptr, | 34       nullptr, make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory()), | 
| 34       make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory(nullptr)), | 35       nullptr, protocol::NetworkSettings( | 
| 35       protocol::NetworkSettings( | 36                    protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING), | 
| 36           protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING), |  | 
| 37       role); | 37       role); | 
| 38 } | 38 } | 
| 39 #endif  // !defined(OS_NACL) | 39 #endif  // !defined(OS_NACL) | 
| 40 | 40 | 
| 41 TransportContext::TransportContext( | 41 TransportContext::TransportContext( | 
| 42     SignalStrategy* signal_strategy, | 42     SignalStrategy* signal_strategy, | 
| 43     scoped_ptr<PortAllocatorFactory> port_allocator_factory, | 43     scoped_ptr<PortAllocatorFactory> port_allocator_factory, | 
|  | 44     scoped_ptr<UrlRequestFactory> url_request_factory, | 
| 44     const NetworkSettings& network_settings, | 45     const NetworkSettings& network_settings, | 
| 45     TransportRole role) | 46     TransportRole role) | 
| 46     : signal_strategy_(signal_strategy), | 47     : signal_strategy_(signal_strategy), | 
| 47       port_allocator_factory_(std::move(port_allocator_factory)), | 48       port_allocator_factory_(std::move(port_allocator_factory)), | 
|  | 49       url_request_factory_(std::move(url_request_factory)), | 
| 48       network_settings_(network_settings), | 50       network_settings_(network_settings), | 
| 49       role_(role) {} | 51       role_(role) {} | 
| 50 | 52 | 
| 51 TransportContext::~TransportContext() {} | 53 TransportContext::~TransportContext() {} | 
| 52 | 54 | 
| 53 void TransportContext::Prepare() { | 55 void TransportContext::Prepare() { | 
| 54   EnsureFreshJingleInfo(); | 56   EnsureFreshJingleInfo(); | 
| 55 } | 57 } | 
| 56 | 58 | 
| 57 void TransportContext::GetJingleInfo(const GetJingleInfoCallback& callback) { | 59 void TransportContext::GetJingleInfo(const GetJingleInfoCallback& callback) { | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 100 | 102 | 
| 101   while (!pending_jingle_info_callbacks_.empty()) { | 103   while (!pending_jingle_info_callbacks_.empty()) { | 
| 102     pending_jingle_info_callbacks_.begin()->Run(stun_hosts_, relay_hosts_, | 104     pending_jingle_info_callbacks_.begin()->Run(stun_hosts_, relay_hosts_, | 
| 103                                                 relay_token_); | 105                                                 relay_token_); | 
| 104     pending_jingle_info_callbacks_.pop_front(); | 106     pending_jingle_info_callbacks_.pop_front(); | 
| 105   } | 107   } | 
| 106 } | 108 } | 
| 107 | 109 | 
| 108 }  // namespace protocol | 110 }  // namespace protocol | 
| 109 }  // namespace remoting | 111 }  // namespace remoting | 
| OLD | NEW | 
|---|