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

Side by Side Diff: webrtc/p2p/base/dtlstransport.h

Issue 1335923002: Add RTC_ prefix to (D)CHECKs and related macros. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 5 years, 3 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/overrides/webrtc/base/logging.cc ('k') | webrtc/p2p/base/dtlstransportchannel.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 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 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 #ifndef WEBRTC_P2P_BASE_DTLSTRANSPORT_H_ 11 #ifndef WEBRTC_P2P_BASE_DTLSTRANSPORT_H_
12 #define WEBRTC_P2P_BASE_DTLSTRANSPORT_H_ 12 #define WEBRTC_P2P_BASE_DTLSTRANSPORT_H_
13 13
14 #include "webrtc/base/checks.h" 14 #include "webrtc/base/checks.h"
15 #include "webrtc/p2p/base/dtlstransportchannel.h" 15 #include "webrtc/p2p/base/dtlstransportchannel.h"
16 #include "webrtc/p2p/base/transport.h" 16 #include "webrtc/p2p/base/transport.h"
17 17
18 namespace rtc { 18 namespace rtc {
19 class SSLIdentity; 19 class SSLIdentity;
20 } 20 }
21 21
22 namespace cricket { 22 namespace cricket {
23 23
24 class PortAllocator; 24 class PortAllocator;
25 25
26 // Base should be a descendant of cricket::Transport 26 // Base should be a descendant of cricket::Transport
27 // TODO(hbos): Add appropriate DCHECK thread checks to all methods. 27 // TODO(hbos): Add appropriate RTC_DCHECK thread checks to all methods.
28 template<class Base> 28 template<class Base>
29 class DtlsTransport : public Base { 29 class DtlsTransport : public Base {
30 public: 30 public:
31 DtlsTransport(rtc::Thread* signaling_thread, 31 DtlsTransport(rtc::Thread* signaling_thread,
32 rtc::Thread* worker_thread, 32 rtc::Thread* worker_thread,
33 const std::string& content_name, 33 const std::string& content_name,
34 PortAllocator* allocator, 34 PortAllocator* allocator,
35 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) 35 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate)
36 : Base(signaling_thread, worker_thread, content_name, allocator), 36 : Base(signaling_thread, worker_thread, content_name, allocator),
37 certificate_(certificate), 37 certificate_(certificate),
38 secure_role_(rtc::SSL_CLIENT), 38 secure_role_(rtc::SSL_CLIENT),
39 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_10) { 39 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_10) {
40 } 40 }
41 41
42 ~DtlsTransport() { 42 ~DtlsTransport() {
43 Base::DestroyAllChannels(); 43 Base::DestroyAllChannels();
44 } 44 }
45 void SetCertificate_w( 45 void SetCertificate_w(
46 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override { 46 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override {
47 DCHECK(Base::worker_thread()->IsCurrent()); 47 RTC_DCHECK(Base::worker_thread()->IsCurrent());
48 certificate_ = certificate; 48 certificate_ = certificate;
49 } 49 }
50 bool GetCertificate_w( 50 bool GetCertificate_w(
51 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override { 51 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override {
52 DCHECK(Base::worker_thread()->IsCurrent()); 52 RTC_DCHECK(Base::worker_thread()->IsCurrent());
53 if (!certificate_) 53 if (!certificate_)
54 return false; 54 return false;
55 55
56 *certificate = certificate_; 56 *certificate = certificate_;
57 return true; 57 return true;
58 } 58 }
59 59
60 bool SetSslMaxProtocolVersion_w(rtc::SSLProtocolVersion version) override { 60 bool SetSslMaxProtocolVersion_w(rtc::SSLProtocolVersion version) override {
61 DCHECK(Base::worker_thread()->IsCurrent()); 61 RTC_DCHECK(Base::worker_thread()->IsCurrent());
62 ssl_max_version_ = version; 62 ssl_max_version_ = version;
63 return true; 63 return true;
64 } 64 }
65 65
66 bool ApplyLocalTransportDescription_w(TransportChannelImpl* channel, 66 bool ApplyLocalTransportDescription_w(TransportChannelImpl* channel,
67 std::string* error_desc) override { 67 std::string* error_desc) override {
68 DCHECK(Base::worker_thread()->IsCurrent()); 68 RTC_DCHECK(Base::worker_thread()->IsCurrent());
69 rtc::SSLFingerprint* local_fp = 69 rtc::SSLFingerprint* local_fp =
70 Base::local_description()->identity_fingerprint.get(); 70 Base::local_description()->identity_fingerprint.get();
71 71
72 if (local_fp) { 72 if (local_fp) {
73 // Sanity check local fingerprint. 73 // Sanity check local fingerprint.
74 if (certificate_) { 74 if (certificate_) {
75 rtc::scoped_ptr<rtc::SSLFingerprint> local_fp_tmp( 75 rtc::scoped_ptr<rtc::SSLFingerprint> local_fp_tmp(
76 rtc::SSLFingerprint::Create(local_fp->algorithm, 76 rtc::SSLFingerprint::Create(local_fp->algorithm,
77 certificate_->identity())); 77 certificate_->identity()));
78 ASSERT(local_fp_tmp.get() != NULL); 78 ASSERT(local_fp_tmp.get() != NULL);
(...skipping 17 matching lines...) Expand all
96 return BadTransportDescription("Failed to set local identity.", 96 return BadTransportDescription("Failed to set local identity.",
97 error_desc); 97 error_desc);
98 } 98 }
99 99
100 // Apply the description in the base class. 100 // Apply the description in the base class.
101 return Base::ApplyLocalTransportDescription_w(channel, error_desc); 101 return Base::ApplyLocalTransportDescription_w(channel, error_desc);
102 } 102 }
103 103
104 bool NegotiateTransportDescription_w(ContentAction local_role, 104 bool NegotiateTransportDescription_w(ContentAction local_role,
105 std::string* error_desc) override { 105 std::string* error_desc) override {
106 DCHECK(Base::worker_thread()->IsCurrent()); 106 RTC_DCHECK(Base::worker_thread()->IsCurrent());
107 if (!Base::local_description() || !Base::remote_description()) { 107 if (!Base::local_description() || !Base::remote_description()) {
108 const std::string msg = "Local and Remote description must be set before " 108 const std::string msg = "Local and Remote description must be set before "
109 "transport descriptions are negotiated"; 109 "transport descriptions are negotiated";
110 return BadTransportDescription(msg, error_desc); 110 return BadTransportDescription(msg, error_desc);
111 } 111 }
112 112
113 rtc::SSLFingerprint* local_fp = 113 rtc::SSLFingerprint* local_fp =
114 Base::local_description()->identity_fingerprint.get(); 114 Base::local_description()->identity_fingerprint.get();
115 rtc::SSLFingerprint* remote_fp = 115 rtc::SSLFingerprint* remote_fp =
116 Base::remote_description()->identity_fingerprint.get(); 116 Base::remote_description()->identity_fingerprint.get();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void DestroyTransportChannel(TransportChannelImpl* channel) override { 213 void DestroyTransportChannel(TransportChannelImpl* channel) override {
214 // Kind of ugly, but this lets us do the exact inverse of the create. 214 // Kind of ugly, but this lets us do the exact inverse of the create.
215 DtlsTransportChannelWrapper* dtls_channel = 215 DtlsTransportChannelWrapper* dtls_channel =
216 static_cast<DtlsTransportChannelWrapper*>(channel); 216 static_cast<DtlsTransportChannelWrapper*>(channel);
217 TransportChannelImpl* base_channel = dtls_channel->channel(); 217 TransportChannelImpl* base_channel = dtls_channel->channel();
218 delete dtls_channel; 218 delete dtls_channel;
219 Base::DestroyTransportChannel(base_channel); 219 Base::DestroyTransportChannel(base_channel);
220 } 220 }
221 221
222 bool GetSslRole_w(rtc::SSLRole* ssl_role) const override { 222 bool GetSslRole_w(rtc::SSLRole* ssl_role) const override {
223 DCHECK(Base::worker_thread()->IsCurrent()); 223 RTC_DCHECK(Base::worker_thread()->IsCurrent());
224 ASSERT(ssl_role != NULL); 224 ASSERT(ssl_role != NULL);
225 *ssl_role = secure_role_; 225 *ssl_role = secure_role_;
226 return true; 226 return true;
227 } 227 }
228 228
229 private: 229 private:
230 bool ApplyNegotiatedTransportDescription_w( 230 bool ApplyNegotiatedTransportDescription_w(
231 TransportChannelImpl* channel, 231 TransportChannelImpl* channel,
232 std::string* error_desc) override { 232 std::string* error_desc) override {
233 DCHECK(Base::worker_thread()->IsCurrent()); 233 RTC_DCHECK(Base::worker_thread()->IsCurrent());
234 // Set ssl role. Role must be set before fingerprint is applied, which 234 // Set ssl role. Role must be set before fingerprint is applied, which
235 // initiates DTLS setup. 235 // initiates DTLS setup.
236 if (!channel->SetSslRole(secure_role_)) { 236 if (!channel->SetSslRole(secure_role_)) {
237 return BadTransportDescription("Failed to set ssl role for the channel.", 237 return BadTransportDescription("Failed to set ssl role for the channel.",
238 error_desc); 238 error_desc);
239 } 239 }
240 // Apply remote fingerprint. 240 // Apply remote fingerprint.
241 if (!channel->SetRemoteFingerprint( 241 if (!channel->SetRemoteFingerprint(
242 remote_fingerprint_->algorithm, 242 remote_fingerprint_->algorithm,
243 reinterpret_cast<const uint8*>(remote_fingerprint_->digest.data()), 243 reinterpret_cast<const uint8*>(remote_fingerprint_->digest.data()),
244 remote_fingerprint_->digest.size())) { 244 remote_fingerprint_->digest.size())) {
245 return BadTransportDescription("Failed to apply remote fingerprint.", 245 return BadTransportDescription("Failed to apply remote fingerprint.",
246 error_desc); 246 error_desc);
247 } 247 }
248 return Base::ApplyNegotiatedTransportDescription_w(channel, error_desc); 248 return Base::ApplyNegotiatedTransportDescription_w(channel, error_desc);
249 } 249 }
250 250
251 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; 251 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
252 rtc::SSLRole secure_role_; 252 rtc::SSLRole secure_role_;
253 rtc::SSLProtocolVersion ssl_max_version_; 253 rtc::SSLProtocolVersion ssl_max_version_;
254 rtc::scoped_ptr<rtc::SSLFingerprint> remote_fingerprint_; 254 rtc::scoped_ptr<rtc::SSLFingerprint> remote_fingerprint_;
255 }; 255 };
256 256
257 } // namespace cricket 257 } // namespace cricket
258 258
259 #endif // WEBRTC_P2P_BASE_DTLSTRANSPORT_H_ 259 #endif // WEBRTC_P2P_BASE_DTLSTRANSPORT_H_
OLDNEW
« no previous file with comments | « webrtc/overrides/webrtc/base/logging.cc ('k') | webrtc/p2p/base/dtlstransportchannel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698