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

Side by Side Diff: webrtc/base/sslsocketfactory.cc

Issue 2620303003: Replace ASSERT by RTC_DCHECK in all non-test code. (Closed)
Patch Set: Address final nits. Created 3 years, 11 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 | « webrtc/base/sslidentity.cc ('k') | webrtc/base/stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2007 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
11 #include <memory> 11 #include <memory>
12 12
13 #include "webrtc/base/autodetectproxy.h" 13 #include "webrtc/base/autodetectproxy.h"
14 #include "webrtc/base/checks.h"
14 #include "webrtc/base/httpcommon.h" 15 #include "webrtc/base/httpcommon.h"
15 #include "webrtc/base/httpcommon-inl.h" 16 #include "webrtc/base/httpcommon-inl.h"
16 #include "webrtc/base/socketadapters.h" 17 #include "webrtc/base/socketadapters.h"
17 #include "webrtc/base/ssladapter.h" 18 #include "webrtc/base/ssladapter.h"
18 #include "webrtc/base/sslsocketfactory.h" 19 #include "webrtc/base/sslsocketfactory.h"
19 20
20 namespace rtc { 21 namespace rtc {
21 22
22 /////////////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////////////
23 // ProxySocketAdapter 24 // ProxySocketAdapter
24 // TODO: Consider combining AutoDetectProxy and ProxySocketAdapter. I think 25 // TODO: Consider combining AutoDetectProxy and ProxySocketAdapter. I think
25 // the socket adapter is the more appropriate idiom for automatic proxy 26 // the socket adapter is the more appropriate idiom for automatic proxy
26 // detection. We may or may not want to combine proxydetect.* as well. 27 // detection. We may or may not want to combine proxydetect.* as well.
27 /////////////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////////////
28 29
29 class ProxySocketAdapter : public AsyncSocketAdapter { 30 class ProxySocketAdapter : public AsyncSocketAdapter {
30 public: 31 public:
31 ProxySocketAdapter(SslSocketFactory* factory, int family, int type) 32 ProxySocketAdapter(SslSocketFactory* factory, int family, int type)
32 : AsyncSocketAdapter(NULL), factory_(factory), family_(family), 33 : AsyncSocketAdapter(NULL), factory_(factory), family_(family),
33 type_(type), detect_(NULL) { 34 type_(type), detect_(NULL) {
34 } 35 }
35 ~ProxySocketAdapter() override { 36 ~ProxySocketAdapter() override {
36 Close(); 37 Close();
37 } 38 }
38 39
39 int Connect(const SocketAddress& addr) override { 40 int Connect(const SocketAddress& addr) override {
40 ASSERT(NULL == detect_); 41 RTC_DCHECK(NULL == detect_);
41 ASSERT(NULL == socket_); 42 RTC_DCHECK(NULL == socket_);
42 remote_ = addr; 43 remote_ = addr;
43 if (remote_.IsAnyIP() && remote_.hostname().empty()) { 44 if (remote_.IsAnyIP() && remote_.hostname().empty()) {
44 LOG_F(LS_ERROR) << "Empty address"; 45 LOG_F(LS_ERROR) << "Empty address";
45 return SOCKET_ERROR; 46 return SOCKET_ERROR;
46 } 47 }
47 Url<char> url("/", remote_.HostAsURIString(), remote_.port()); 48 Url<char> url("/", remote_.HostAsURIString(), remote_.port());
48 detect_ = new AutoDetectProxy(factory_->agent_); 49 detect_ = new AutoDetectProxy(factory_->agent_);
49 detect_->set_server_url(url.url()); 50 detect_->set_server_url(url.url());
50 detect_->SignalWorkDone.connect(this, 51 detect_->SignalWorkDone.connect(this,
51 &ProxySocketAdapter::OnProxyDetectionComplete); 52 &ProxySocketAdapter::OnProxyDetectionComplete);
(...skipping 19 matching lines...) Expand all
71 ConnState GetState() const override { 72 ConnState GetState() const override {
72 if (socket_) { 73 if (socket_) {
73 return socket_->GetState(); 74 return socket_->GetState();
74 } 75 }
75 return detect_ ? CS_CONNECTING : CS_CLOSED; 76 return detect_ ? CS_CONNECTING : CS_CLOSED;
76 } 77 }
77 78
78 private: 79 private:
79 // AutoDetectProxy Slots 80 // AutoDetectProxy Slots
80 void OnProxyDetectionComplete(SignalThread* thread) { 81 void OnProxyDetectionComplete(SignalThread* thread) {
81 ASSERT(detect_ == thread); 82 RTC_DCHECK(detect_ == thread);
82 Attach(factory_->CreateProxySocket(detect_->proxy(), family_, type_)); 83 Attach(factory_->CreateProxySocket(detect_->proxy(), family_, type_));
83 detect_->Release(); 84 detect_->Release();
84 detect_ = NULL; 85 detect_ = NULL;
85 if (0 == AsyncSocketAdapter::Connect(remote_)) { 86 if (0 == AsyncSocketAdapter::Connect(remote_)) {
86 SignalConnectEvent(this); 87 SignalConnectEvent(this);
87 } else if (!IsBlockingError(socket_->GetError())) { 88 } else if (!IsBlockingError(socket_->GetError())) {
88 SignalCloseEvent(this, socket_->GetError()); 89 SignalCloseEvent(this, socket_->GetError());
89 } 90 }
90 } 91 }
91 92
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (!logging_label_.empty() && !binary_mode_) { 188 if (!logging_label_.empty() && !binary_mode_) {
188 socket = new LoggingSocketAdapter(socket, logging_level_, 189 socket = new LoggingSocketAdapter(socket, logging_level_,
189 logging_label_.c_str(), binary_mode_); 190 logging_label_.c_str(), binary_mode_);
190 } 191 }
191 return socket; 192 return socket;
192 } 193 }
193 194
194 /////////////////////////////////////////////////////////////////////////////// 195 ///////////////////////////////////////////////////////////////////////////////
195 196
196 } // namespace rtc 197 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/sslidentity.cc ('k') | webrtc/base/stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698