Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: remoting/protocol/transport_context.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/protocol/transport_context.h ('k') | remoting/protocol/v2_authenticator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ptr_util.h"
11 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
12 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
13 #include "remoting/base/url_request.h" 14 #include "remoting/base/url_request.h"
14 #include "remoting/protocol/http_ice_config_request.h" 15 #include "remoting/protocol/http_ice_config_request.h"
15 #include "remoting/protocol/jingle_info_request.h" 16 #include "remoting/protocol/jingle_info_request.h"
16 #include "remoting/protocol/port_allocator_factory.h" 17 #include "remoting/protocol/port_allocator_factory.h"
17 #include "third_party/webrtc/base/socketaddress.h" 18 #include "third_party/webrtc/base/socketaddress.h"
18 19
19 #if !defined(OS_NACL) 20 #if !defined(OS_NACL)
20 #include "jingle/glue/thread_wrapper.h" 21 #include "jingle/glue/thread_wrapper.h"
21 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
22 #include "remoting/protocol/chromium_port_allocator_factory.h" 23 #include "remoting/protocol/chromium_port_allocator_factory.h"
23 #endif // !defined(OS_NACL) 24 #endif // !defined(OS_NACL)
24 25
25 namespace remoting { 26 namespace remoting {
26 namespace protocol { 27 namespace protocol {
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, make_scoped_ptr(new protocol::ChromiumPortAllocatorFactory()), 34 nullptr, base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()),
34 nullptr, protocol::NetworkSettings( 35 nullptr, protocol::NetworkSettings(
35 protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING), 36 protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING),
36 role); 37 role);
37 } 38 }
38 #endif // !defined(OS_NACL) 39 #endif // !defined(OS_NACL)
39 40
40 TransportContext::TransportContext( 41 TransportContext::TransportContext(
41 SignalStrategy* signal_strategy, 42 SignalStrategy* signal_strategy,
42 scoped_ptr<PortAllocatorFactory> port_allocator_factory, 43 std::unique_ptr<PortAllocatorFactory> port_allocator_factory,
43 scoped_ptr<UrlRequestFactory> url_request_factory, 44 std::unique_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)),
48 url_request_factory_(std::move(url_request_factory)), 49 url_request_factory_(std::move(url_request_factory)),
49 network_settings_(network_settings), 50 network_settings_(network_settings),
50 role_(role) {} 51 role_(role) {}
51 52
52 TransportContext::~TransportContext() {} 53 TransportContext::~TransportContext() {}
53 54
(...skipping 19 matching lines...) Expand all
73 return; 74 return;
74 75
75 // Don't need to make jingleinfo request if both STUN and Relay are disabled. 76 // Don't need to make jingleinfo request if both STUN and Relay are disabled.
76 if ((network_settings_.flags & (NetworkSettings::NAT_TRAVERSAL_STUN | 77 if ((network_settings_.flags & (NetworkSettings::NAT_TRAVERSAL_STUN |
77 NetworkSettings::NAT_TRAVERSAL_RELAY)) == 0) { 78 NetworkSettings::NAT_TRAVERSAL_RELAY)) == 0) {
78 return; 79 return;
79 } 80 }
80 81
81 if (ice_config_[relay_mode_].is_null() || 82 if (ice_config_[relay_mode_].is_null() ||
82 base::Time::Now() > ice_config_[relay_mode_].expiration_time) { 83 base::Time::Now() > ice_config_[relay_mode_].expiration_time) {
83 scoped_ptr<IceConfigRequest> request; 84 std::unique_ptr<IceConfigRequest> request;
84 switch (relay_mode_) { 85 switch (relay_mode_) {
85 case RelayMode::TURN: 86 case RelayMode::TURN:
86 if (ice_config_url_.empty()) { 87 if (ice_config_url_.empty()) {
87 LOG(WARNING) << "ice_config_url isn't set."; 88 LOG(WARNING) << "ice_config_url isn't set.";
88 return; 89 return;
89 } 90 }
90 request.reset(new HttpIceConfigRequest(url_request_factory_.get(), 91 request.reset(new HttpIceConfigRequest(url_request_factory_.get(),
91 ice_config_url_)); 92 ice_config_url_));
92 break; 93 break;
93 case RelayMode::GTURN: 94 case RelayMode::GTURN:
(...skipping 13 matching lines...) Expand all
107 108
108 auto& callback_list = pending_ice_config_callbacks_[relay_mode]; 109 auto& callback_list = pending_ice_config_callbacks_[relay_mode];
109 while (!callback_list.empty()) { 110 while (!callback_list.empty()) {
110 callback_list.begin()->Run(ice_config); 111 callback_list.begin()->Run(ice_config);
111 callback_list.pop_front(); 112 callback_list.pop_front();
112 } 113 }
113 } 114 }
114 115
115 } // namespace protocol 116 } // namespace protocol
116 } // namespace remoting 117 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/transport_context.h ('k') | remoting/protocol/v2_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698