| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 void AutoDetectProxy::OnResolveResult(AsyncResolverInterface* resolver) { | 131 void AutoDetectProxy::OnResolveResult(AsyncResolverInterface* resolver) { |
| 132 if (resolver != resolver_) { | 132 if (resolver != resolver_) { |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 int error = resolver_->GetError(); | 135 int error = resolver_->GetError(); |
| 136 if (error == 0) { | 136 if (error == 0) { |
| 137 LOG(LS_VERBOSE) << "Resolved " << proxy_.address << " to " | 137 LOG(LS_VERBOSE) << "Resolved " << proxy_.address << " to " |
| 138 << resolver_->address(); | 138 << resolver_->address(); |
| 139 proxy_.address = resolver_->address(); | 139 proxy_.address = resolver_->address(); |
| 140 if (!DoConnect()) { | 140 if (!DoConnect()) { |
| 141 Thread::Current()->Post(this, MSG_TIMEOUT); | 141 Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TIMEOUT); |
| 142 } | 142 } |
| 143 } else { | 143 } else { |
| 144 LOG(LS_INFO) << "Failed to resolve " << resolver_->address(); | 144 LOG(LS_INFO) << "Failed to resolve " << resolver_->address(); |
| 145 resolver_->Destroy(false); | 145 resolver_->Destroy(false); |
| 146 resolver_ = NULL; | 146 resolver_ = NULL; |
| 147 proxy_.address = SocketAddress(); | 147 proxy_.address = SocketAddress(); |
| 148 Thread::Current()->Post(this, MSG_UNRESOLVABLE); | 148 Thread::Current()->Post(RTC_FROM_HERE, this, MSG_UNRESOLVABLE); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 void AutoDetectProxy::Next() { | 152 void AutoDetectProxy::Next() { |
| 153 if (TEST_ORDER[next_] >= PROXY_UNKNOWN) { | 153 if (TEST_ORDER[next_] >= PROXY_UNKNOWN) { |
| 154 Complete(PROXY_UNKNOWN); | 154 Complete(PROXY_UNKNOWN); |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 | 157 |
| 158 LOG(LS_VERBOSE) << "AutoDetectProxy connecting to " | 158 LOG(LS_VERBOSE) << "AutoDetectProxy connecting to " |
| (...skipping 10 matching lines...) Expand all Loading... |
| 169 if (proxy_.address.IsUnresolvedIP()) { | 169 if (proxy_.address.IsUnresolvedIP()) { |
| 170 // Launch an asyncresolver. This thread will spin waiting for it. | 170 // Launch an asyncresolver. This thread will spin waiting for it. |
| 171 timeout += 2000; | 171 timeout += 2000; |
| 172 if (!resolver_) { | 172 if (!resolver_) { |
| 173 resolver_ = new AsyncResolver(); | 173 resolver_ = new AsyncResolver(); |
| 174 } | 174 } |
| 175 resolver_->SignalDone.connect(this, &AutoDetectProxy::OnResolveResult); | 175 resolver_->SignalDone.connect(this, &AutoDetectProxy::OnResolveResult); |
| 176 resolver_->Start(proxy_.address); | 176 resolver_->Start(proxy_.address); |
| 177 } else { | 177 } else { |
| 178 if (!DoConnect()) { | 178 if (!DoConnect()) { |
| 179 Thread::Current()->Post(this, MSG_TIMEOUT); | 179 Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TIMEOUT); |
| 180 return; | 180 return; |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 Thread::Current()->PostDelayed(timeout, this, MSG_TIMEOUT); | 183 Thread::Current()->PostDelayed(RTC_FROM_HERE, timeout, this, MSG_TIMEOUT); |
| 184 } | 184 } |
| 185 | 185 |
| 186 bool AutoDetectProxy::DoConnect() { | 186 bool AutoDetectProxy::DoConnect() { |
| 187 if (resolver_) { | 187 if (resolver_) { |
| 188 resolver_->Destroy(false); | 188 resolver_->Destroy(false); |
| 189 resolver_ = NULL; | 189 resolver_ = NULL; |
| 190 } | 190 } |
| 191 socket_ = | 191 socket_ = |
| 192 Thread::Current()->socketserver()->CreateAsyncSocket( | 192 Thread::Current()->socketserver()->CreateAsyncSocket( |
| 193 proxy_.address.family(), SOCK_STREAM); | 193 proxy_.address.family(), SOCK_STREAM); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 Next(); | 279 Next(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void AutoDetectProxy::OnCloseEvent(AsyncSocket * socket, int error) { | 282 void AutoDetectProxy::OnCloseEvent(AsyncSocket * socket, int error) { |
| 283 LOG(LS_VERBOSE) << "AutoDetectProxy closed with error: " << error; | 283 LOG(LS_VERBOSE) << "AutoDetectProxy closed with error: " << error; |
| 284 ++next_; | 284 ++next_; |
| 285 Next(); | 285 Next(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace rtc | 288 } // namespace rtc |
| OLD | NEW |