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

Side by Side Diff: extensions/browser/api/cast_channel/cast_channel_api.cc

Issue 2137013005: [Extensions] Code Cleanup - Remove redundant smart-ptr get()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_channel_api.h" 5 #include "extensions/browser/api/cast_channel/cast_channel_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 params_ = Open::Params::Create(*args_); 264 params_ = Open::Params::Create(*args_);
265 EXTENSION_FUNCTION_VALIDATE(params_.get()); 265 EXTENSION_FUNCTION_VALIDATE(params_.get());
266 const ConnectInfo& connect_info = params_->connect_info; 266 const ConnectInfo& connect_info = params_->connect_info;
267 if (!IsValidConnectInfoPort(connect_info)) { 267 if (!IsValidConnectInfoPort(connect_info)) {
268 SetError("Invalid connect_info (invalid port)"); 268 SetError("Invalid connect_info (invalid port)");
269 } else if (!IsValidConnectInfoIpAddress(connect_info)) { 269 } else if (!IsValidConnectInfoIpAddress(connect_info)) {
270 SetError("Invalid connect_info (invalid IP address)"); 270 SetError("Invalid connect_info (invalid IP address)");
271 } else { 271 } else {
272 // Parse timeout parameters if they are set. 272 // Parse timeout parameters if they are set.
273 if (connect_info.liveness_timeout.get()) { 273 if (connect_info.liveness_timeout.get()) {
274 liveness_timeout_ = base::TimeDelta::FromMilliseconds( 274 liveness_timeout_ =
275 *connect_info.liveness_timeout.get()); 275 base::TimeDelta::FromMilliseconds(*connect_info.liveness_timeout);
276 } 276 }
277 if (connect_info.ping_interval.get()) { 277 if (connect_info.ping_interval.get()) {
278 ping_interval_ = 278 ping_interval_ =
279 base::TimeDelta::FromMilliseconds(*connect_info.ping_interval.get()); 279 base::TimeDelta::FromMilliseconds(*connect_info.ping_interval);
280 } 280 }
281 281
282 // Validate timeout parameters. 282 // Validate timeout parameters.
283 if (liveness_timeout_ < base::TimeDelta() || 283 if (liveness_timeout_ < base::TimeDelta() ||
284 ping_interval_ < base::TimeDelta()) { 284 ping_interval_ < base::TimeDelta()) {
285 SetError("livenessTimeout and pingInterval must be greater than 0."); 285 SetError("livenessTimeout and pingInterval must be greater than 0.");
286 } else if ((liveness_timeout_ > base::TimeDelta()) != 286 } else if ((liveness_timeout_ > base::TimeDelta()) !=
287 (ping_interval_ > base::TimeDelta())) { 287 (ping_interval_ > base::TimeDelta())) {
288 SetError("livenessTimeout and pingInterval must be set together."); 288 SetError("livenessTimeout and pingInterval must be set together.");
289 } else if (liveness_timeout_ < ping_interval_) { 289 } else if (liveness_timeout_ < ping_interval_) {
(...skipping 16 matching lines...) Expand all
306 const ConnectInfo& connect_info = params_->connect_info; 306 const ConnectInfo& connect_info = params_->connect_info;
307 CastSocket* socket; 307 CastSocket* socket;
308 std::unique_ptr<CastSocket> test_socket = api_->GetSocketForTest(); 308 std::unique_ptr<CastSocket> test_socket = api_->GetSocketForTest();
309 if (test_socket.get()) { 309 if (test_socket.get()) {
310 socket = test_socket.release(); 310 socket = test_socket.release();
311 } else { 311 } else {
312 socket = new cast_channel::CastSocketImpl( 312 socket = new cast_channel::CastSocketImpl(
313 extension_->id(), *ip_endpoint_, channel_auth_, 313 extension_->id(), *ip_endpoint_, channel_auth_,
314 ExtensionsBrowserClient::Get()->GetNetLog(), 314 ExtensionsBrowserClient::Get()->GetNetLog(),
315 base::TimeDelta::FromMilliseconds(connect_info.timeout.get() 315 base::TimeDelta::FromMilliseconds(connect_info.timeout.get()
316 ? *connect_info.timeout.get() 316 ? *connect_info.timeout
317 : kDefaultConnectTimeoutMillis), 317 : kDefaultConnectTimeoutMillis),
318 liveness_timeout_ > base::TimeDelta(), api_->GetLogger(), 318 liveness_timeout_ > base::TimeDelta(), api_->GetLogger(),
319 connect_info.capabilities.get() ? *connect_info.capabilities.get() 319 connect_info.capabilities.get() ? *connect_info.capabilities
320 : CastDeviceCapability::NONE); 320 : CastDeviceCapability::NONE);
321 } 321 }
322 new_channel_id_ = AddSocket(socket); 322 new_channel_id_ = AddSocket(socket);
323 api_->GetLogger()->LogNewSocketEvent(*socket); 323 api_->GetLogger()->LogNewSocketEvent(*socket);
324 324
325 // Construct read delegates. 325 // Construct read delegates.
326 std::unique_ptr<api::cast_channel::CastTransport::Delegate> delegate( 326 std::unique_ptr<api::cast_channel::CastTransport::Delegate> delegate(
327 base::WrapUnique(new CastMessageHandler( 327 base::WrapUnique(new CastMessageHandler(
328 base::Bind(&CastChannelAPI::SendEvent, api_->AsWeakPtr()), socket, 328 base::Bind(&CastChannelAPI::SendEvent, api_->AsWeakPtr()), socket,
329 api_->GetLogger()))); 329 api_->GetLogger())));
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 return true; 558 return true;
559 } 559 }
560 560
561 void CastChannelSetAuthorityKeysFunction::AsyncWorkStart() { 561 void CastChannelSetAuthorityKeysFunction::AsyncWorkStart() {
562 // TODO(eroman): crbug.com/601171: Delete this once the API is 562 // TODO(eroman): crbug.com/601171: Delete this once the API is
563 // removed. It is currently a no-op. 563 // removed. It is currently a no-op.
564 AsyncWorkCompleted(); 564 AsyncWorkCompleted();
565 } 565 }
566 566
567 } // namespace extensions 567 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698