OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/http_ice_config_request.h" | 5 #include "remoting/protocol/http_ice_config_request.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 if (result.status != 200) { | 125 if (result.status != 200) { |
126 LOG(ERROR) << "Received status code " << result.status << " from " << url_ | 126 LOG(ERROR) << "Received status code " << result.status << " from " << url_ |
127 << ": " << result.response_body; | 127 << ": " << result.response_body; |
128 base::ResetAndReturn(&on_ice_config_callback_).Run(IceConfig()); | 128 base::ResetAndReturn(&on_ice_config_callback_).Run(IceConfig()); |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 scoped_ptr<base::Value> json = base::JSONReader::Read(result.response_body); | 132 std::unique_ptr<base::Value> json = |
| 133 base::JSONReader::Read(result.response_body); |
133 base::DictionaryValue* dictionary = nullptr; | 134 base::DictionaryValue* dictionary = nullptr; |
134 base::ListValue* ice_servers_list = nullptr; | 135 base::ListValue* ice_servers_list = nullptr; |
135 if (!json || !json->GetAsDictionary(&dictionary) || | 136 if (!json || !json->GetAsDictionary(&dictionary) || |
136 !dictionary->GetList("iceServers", &ice_servers_list)) { | 137 !dictionary->GetList("iceServers", &ice_servers_list)) { |
137 LOG(ERROR) << "Received invalid response from " << url_ << ": " | 138 LOG(ERROR) << "Received invalid response from " << url_ << ": " |
138 << result.response_body; | 139 << result.response_body; |
139 base::ResetAndReturn(&on_ice_config_callback_).Run(IceConfig()); | 140 base::ResetAndReturn(&on_ice_config_callback_).Run(IceConfig()); |
140 return; | 141 return; |
141 } | 142 } |
142 | 143 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 if (errors_found || ice_config.stun_servers.empty() || | 202 if (errors_found || ice_config.stun_servers.empty() || |
202 ice_config.turn_servers.empty()) { | 203 ice_config.turn_servers.empty()) { |
203 ice_config.expiration_time = base::Time::Now(); | 204 ice_config.expiration_time = base::Time::Now(); |
204 } | 205 } |
205 | 206 |
206 base::ResetAndReturn(&on_ice_config_callback_).Run(ice_config); | 207 base::ResetAndReturn(&on_ice_config_callback_).Run(ice_config); |
207 } | 208 } |
208 | 209 |
209 } // namespace protocol | 210 } // namespace protocol |
210 } // namespace remoting | 211 } // namespace remoting |
OLD | NEW |