| 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 #include "chrome/browser/extensions/api/dial/dial_service.h" | 5 #include "chrome/browser/extensions/api/dial/dial_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 DialServiceImpl::DialServiceImpl(net::NetLog* net_log) | 120 DialServiceImpl::DialServiceImpl(net::NetLog* net_log) |
| 121 : is_writing_(false), | 121 : is_writing_(false), |
| 122 is_reading_(false), | 122 is_reading_(false), |
| 123 discovery_active_(false), | 123 discovery_active_(false), |
| 124 num_requests_sent_(0), | 124 num_requests_sent_(0), |
| 125 max_requests_(kDialMaxRequests), | 125 max_requests_(kDialMaxRequests), |
| 126 finish_delay_(TimeDelta::FromMilliseconds((kDialMaxRequests - 1) * | 126 finish_delay_(TimeDelta::FromMilliseconds((kDialMaxRequests - 1) * |
| 127 kDialRequestIntervalMillis) + | 127 kDialRequestIntervalMillis) + |
| 128 TimeDelta::FromSeconds(kDialResponseTimeoutSecs)), | 128 TimeDelta::FromSeconds(kDialResponseTimeoutSecs)), |
| 129 request_interval_(TimeDelta::FromMilliseconds(kDialRequestIntervalMillis)) | 129 request_interval_(TimeDelta::FromMilliseconds(kDialRequestIntervalMillis)) { |
| 130 { | |
| 131 IPAddressNumber address; | 130 IPAddressNumber address; |
| 132 bool result = net::ParseIPLiteralToNumber(kDialRequestAddress, &address); | 131 bool result = net::ParseIPLiteralToNumber(kDialRequestAddress, &address); |
| 133 DCHECK(result); | 132 DCHECK(result); |
| 134 send_address_ = IPEndPoint(address, kDialRequestPort); | 133 send_address_ = IPEndPoint(address, kDialRequestPort); |
| 135 send_buffer_ = new StringIOBuffer(BuildRequest()); | 134 send_buffer_ = new StringIOBuffer(BuildRequest()); |
| 136 net_log_ = net_log; | 135 net_log_ = net_log; |
| 137 net_log_source_.type = net::NetLog::SOURCE_UDP_SOCKET; | 136 net_log_source_.type = net::NetLog::SOURCE_UDP_SOCKET; |
| 138 net_log_source_.id = net_log_->NextID(); | 137 net_log_source_.id = net_log_->NextID(); |
| 139 } | 138 } |
| 140 | 139 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 DVLOG(0) << "dial socket error: " << error_str; | 477 DVLOG(0) << "dial socket error: " << error_str; |
| 479 // TODO(justinlin): More granular socket errors. | 478 // TODO(justinlin): More granular socket errors. |
| 480 FOR_EACH_OBSERVER( | 479 FOR_EACH_OBSERVER( |
| 481 Observer, observer_list_, OnError(this, DIAL_SERVICE_SOCKET_ERROR)); | 480 Observer, observer_list_, OnError(this, DIAL_SERVICE_SOCKET_ERROR)); |
| 482 return false; | 481 return false; |
| 483 } | 482 } |
| 484 return true; | 483 return true; |
| 485 } | 484 } |
| 486 | 485 |
| 487 } // namespace extensions | 486 } // namespace extensions |
| OLD | NEW |