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

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

Issue 2625003003: Replace ASSERT(false) by RTC_NOTREACHED(). (Closed)
Patch Set: 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/diskcache.cc ('k') | webrtc/base/httpclient.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 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
11 #include <memory> 11 #include <memory>
12 12
13 #if defined(WEBRTC_WIN) 13 #if defined(WEBRTC_WIN)
14 #include "webrtc/base/win32.h" 14 #include "webrtc/base/win32.h"
15 #else // !WEBRTC_WIN 15 #else // !WEBRTC_WIN
16 #define SEC_E_CERT_EXPIRED (-2146893016) 16 #define SEC_E_CERT_EXPIRED (-2146893016)
17 #endif // !WEBRTC_WIN 17 #endif // !WEBRTC_WIN
18 18
19 #include "webrtc/base/checks.h"
19 #include "webrtc/base/common.h" 20 #include "webrtc/base/common.h"
20 #include "webrtc/base/httpbase.h" 21 #include "webrtc/base/httpbase.h"
21 #include "webrtc/base/logging.h" 22 #include "webrtc/base/logging.h"
22 #include "webrtc/base/socket.h" 23 #include "webrtc/base/socket.h"
23 #include "webrtc/base/stringutils.h" 24 #include "webrtc/base/stringutils.h"
24 #include "webrtc/base/thread.h" 25 #include "webrtc/base/thread.h"
25 26
26 namespace rtc { 27 namespace rtc {
27 28
28 ////////////////////////////////////////////////////////////////////// 29 //////////////////////////////////////////////////////////////////////
(...skipping 28 matching lines...) Expand all
57 data_size_ = SIZE_UNKNOWN; 58 data_size_ = SIZE_UNKNOWN;
58 } 59 }
59 60
60 HttpParser::ProcessResult 61 HttpParser::ProcessResult
61 HttpParser::Process(const char* buffer, size_t len, size_t* processed, 62 HttpParser::Process(const char* buffer, size_t len, size_t* processed,
62 HttpError* error) { 63 HttpError* error) {
63 *processed = 0; 64 *processed = 0;
64 *error = HE_NONE; 65 *error = HE_NONE;
65 66
66 if (state_ >= ST_COMPLETE) { 67 if (state_ >= ST_COMPLETE) {
67 ASSERT(false); 68 RTC_NOTREACHED();
68 return PR_COMPLETE; 69 return PR_COMPLETE;
69 } 70 }
70 71
71 while (true) { 72 while (true) {
72 if (state_ < ST_DATA) { 73 if (state_ < ST_DATA) {
73 size_t pos = *processed; 74 size_t pos = *processed;
74 while ((pos < len) && (buffer[pos] != '\n')) { 75 while ((pos < len) && (buffer[pos] != '\n')) {
75 pos += 1; 76 pos += 1;
76 } 77 }
77 if (pos >= len) { 78 if (pos >= len) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 break; 200 break;
200 201
201 case ST_TRAILERS: 202 case ST_TRAILERS:
202 if (len == 0) { 203 if (len == 0) {
203 return PR_COMPLETE; 204 return PR_COMPLETE;
204 } 205 }
205 // *error = onHttpRecvTrailer(); 206 // *error = onHttpRecvTrailer();
206 break; 207 break;
207 208
208 default: 209 default:
209 ASSERT(false); 210 RTC_NOTREACHED();
210 break; 211 break;
211 } 212 }
212 213
213 return PR_CONTINUE; 214 return PR_CONTINUE;
214 } 215 }
215 216
216 bool 217 bool
217 HttpParser::is_valid_end_of_input() const { 218 HttpParser::is_valid_end_of_input() const {
218 return (state_ == ST_DATA) && (data_size_ == SIZE_UNKNOWN); 219 return (state_ == ST_DATA) && (data_size_ == SIZE_UNKNOWN);
219 } 220 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 370 }
370 371
371 bool 372 bool
372 HttpBase::isConnected() const { 373 HttpBase::isConnected() const {
373 return (http_stream_ != NULL) && (http_stream_->GetState() == SS_OPEN); 374 return (http_stream_ != NULL) && (http_stream_->GetState() == SS_OPEN);
374 } 375 }
375 376
376 bool 377 bool
377 HttpBase::attach(StreamInterface* stream) { 378 HttpBase::attach(StreamInterface* stream) {
378 if ((mode_ != HM_NONE) || (http_stream_ != NULL) || (stream == NULL)) { 379 if ((mode_ != HM_NONE) || (http_stream_ != NULL) || (stream == NULL)) {
379 ASSERT(false); 380 RTC_NOTREACHED();
380 return false; 381 return false;
381 } 382 }
382 http_stream_ = stream; 383 http_stream_ = stream;
383 http_stream_->SignalEvent.connect(this, &HttpBase::OnHttpStreamEvent); 384 http_stream_->SignalEvent.connect(this, &HttpBase::OnHttpStreamEvent);
384 mode_ = (http_stream_->GetState() == SS_OPENING) ? HM_CONNECT : HM_NONE; 385 mode_ = (http_stream_->GetState() == SS_OPENING) ? HM_CONNECT : HM_NONE;
385 return true; 386 return true;
386 } 387 }
387 388
388 StreamInterface* 389 StreamInterface*
389 HttpBase::detach() { 390 HttpBase::detach() {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 return; 696 return;
696 } 697 }
697 } else { 698 } else {
698 ASSERT(result == SR_ERROR); 699 ASSERT(result == SR_ERROR);
699 LOG_F(LS_ERROR) << "error"; 700 LOG_F(LS_ERROR) << "error";
700 OnHttpStreamEvent(http_stream_, SE_CLOSE, error); 701 OnHttpStreamEvent(http_stream_, SE_CLOSE, error);
701 return; 702 return;
702 } 703 }
703 } 704 }
704 705
705 ASSERT(false); 706 RTC_NOTREACHED();
706 } 707 }
707 708
708 bool 709 bool
709 HttpBase::queue_headers() { 710 HttpBase::queue_headers() {
710 ASSERT(HM_SEND == mode_); 711 ASSERT(HM_SEND == mode_);
711 while (header_ != data_->end()) { 712 while (header_ != data_->end()) {
712 size_t len = sprintfn(buffer_ + len_, sizeof(buffer_) - len_, 713 size_t len = sprintfn(buffer_ + len_, sizeof(buffer_) - len_,
713 "%.*s: %.*s\r\n", 714 "%.*s: %.*s\r\n",
714 header_->first.size(), header_->first.data(), 715 header_->first.size(), header_->first.data(),
715 header_->second.size(), header_->second.data()); 716 header_->second.size(), header_->second.data());
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 874 }
874 } 875 }
875 876
876 void 877 void
877 HttpBase::OnComplete(HttpError err) { 878 HttpBase::OnComplete(HttpError err) {
878 LOG_F(LS_VERBOSE); 879 LOG_F(LS_VERBOSE);
879 do_complete(err); 880 do_complete(err);
880 } 881 }
881 882
882 } // namespace rtc 883 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/diskcache.cc ('k') | webrtc/base/httpclient.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698