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

Unified Diff: webrtc/base/httpclient.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/base/httpclient.cc
diff --git a/webrtc/base/httpclient.cc b/webrtc/base/httpclient.cc
index e65eb9e80c4f05db2f500d91a923f7bee8669d34..a2570c4f4c2a4530e7b7561f5f907a06d2b67884 100644
--- a/webrtc/base/httpclient.cc
+++ b/webrtc/base/httpclient.cc
@@ -37,8 +37,8 @@ const size_t kCacheBody = 1;
// Convert decimal string to integer
bool HttpStringToUInt(const std::string& str, size_t* val) {
- RTC_DCHECK(NULL != val);
- char* eos = NULL;
+ RTC_DCHECK(nullptr != val);
+ char* eos = nullptr;
*val = strtoul(str.c_str(), &eos, 10);
return (*eos == '\0');
}
@@ -46,8 +46,8 @@ bool HttpStringToUInt(const std::string& str, size_t* val) {
bool HttpShouldCache(const HttpTransaction& t) {
bool verb_allows_cache = (t.request.verb == HV_GET)
|| (t.request.verb == HV_HEAD);
- bool is_range_response = t.response.hasHeader(HH_CONTENT_RANGE, NULL);
- bool has_expires = t.response.hasHeader(HH_EXPIRES, NULL);
+ bool is_range_response = t.response.hasHeader(HH_CONTENT_RANGE, nullptr);
+ bool has_expires = t.response.hasHeader(HH_EXPIRES, nullptr);
bool request_allows_cache =
has_expires || (std::string::npos != t.request.path.find('?'));
bool response_allows_cache =
@@ -71,9 +71,9 @@ bool HttpShouldCache(const HttpTransaction& t) {
// s-maxage - use as max-age for shared caches, ignore otherwise
// must-revalidate - may cache, but must revalidate after stale
// proxy-revalidate - shared cache must revalidate
- if (HttpHasAttribute(directives, "no-store", NULL)) {
+ if (HttpHasAttribute(directives, "no-store", nullptr)) {
may_cache = false;
- } else if (HttpHasAttribute(directives, "public", NULL)) {
+ } else if (HttpHasAttribute(directives, "public", nullptr)) {
may_cache = true;
}
}
@@ -155,7 +155,7 @@ HttpValidatorStrength
HttpRequestValidatorLevel(const HttpRequestData& request) {
if (HV_GET != request.verb)
return HVS_STRONG;
- return request.hasHeader(HH_RANGE, NULL) ? HVS_STRONG : HVS_WEAK;
+ return request.hasHeader(HH_RANGE, nullptr) ? HVS_STRONG : HVS_WEAK;
}
HttpValidatorStrength
@@ -209,14 +209,13 @@ bool HttpWriteCacheHeaders(const HttpResponseData* response,
formatted_header.append(": ");
formatted_header.append(it->second);
formatted_header.append("\r\n");
- StreamResult result = output->WriteAll(formatted_header.data(),
- formatted_header.length(),
- NULL, NULL);
+ StreamResult result = output->WriteAll(
+ formatted_header.data(), formatted_header.length(), nullptr, nullptr);
if (SR_SUCCESS != result) {
return false;
}
}
- if (output && (SR_SUCCESS != output->WriteAll("\r\n", 2, NULL, NULL))) {
+ if (output && (SR_SUCCESS != output->WriteAll("\r\n", 2, nullptr, nullptr))) {
return false;
}
length += 2;
@@ -265,23 +264,30 @@ bool HttpReadCacheHeaders(StreamInterface* input, HttpResponseData* response,
const size_t kDefaultRetries = 1;
const size_t kMaxRedirects = 5;
-HttpClient::HttpClient(const std::string& agent, StreamPool* pool,
+HttpClient::HttpClient(const std::string& agent,
+ StreamPool* pool,
HttpTransaction* transaction)
- : agent_(agent), pool_(pool),
- transaction_(transaction), free_transaction_(false),
- retries_(kDefaultRetries), attempt_(0), redirects_(0),
+ : agent_(agent),
+ pool_(pool),
+ transaction_(transaction),
+ free_transaction_(false),
+ retries_(kDefaultRetries),
+ attempt_(0),
+ redirects_(0),
redirect_action_(REDIRECT_DEFAULT),
- uri_form_(URI_DEFAULT), cache_(NULL), cache_state_(CS_READY),
- resolver_(NULL) {
+ uri_form_(URI_DEFAULT),
+ cache_(nullptr),
+ cache_state_(CS_READY),
+ resolver_(nullptr) {
base_.notify(this);
- if (NULL == transaction_) {
+ if (nullptr == transaction_) {
free_transaction_ = true;
transaction_ = new HttpTransaction;
}
}
HttpClient::~HttpClient() {
- base_.notify(NULL);
+ base_.notify(nullptr);
base_.abort(HE_SHUTDOWN);
if (resolver_) {
resolver_->Destroy(false);
@@ -307,7 +313,7 @@ void HttpClient::OnResolveResult(AsyncResolverInterface* resolver) {
int error = resolver_->GetError();
server_ = resolver_->address();
resolver_->Destroy(false);
- resolver_ = NULL;
+ resolver_ = nullptr;
if (error != 0) {
LOG(LS_ERROR) << "Error " << error << " resolving name: "
<< server_;
@@ -343,7 +349,7 @@ void HttpClient::start() {
RTC_DCHECK(!IsCacheActive());
- if (request().hasHeader(HH_TRANSFER_ENCODING, NULL)) {
+ if (request().hasHeader(HH_TRANSFER_ENCODING, nullptr)) {
// Exact size must be known on the client. Instead of using chunked
// encoding, wrap data with auto-caching file or memory stream.
RTC_NOTREACHED();
@@ -388,7 +394,7 @@ void HttpClient::start() {
}
}
- if ((NULL != cache_) && CheckCache()) {
+ if ((nullptr != cache_) && CheckCache()) {
return;
}
@@ -402,7 +408,7 @@ void HttpClient::connect() {
return;
}
StreamInterface* stream = pool_->RequestConnectedStream(server_, &stream_err);
- if (stream == NULL) {
+ if (stream == nullptr) {
RTC_DCHECK(0 != stream_err);
LOG(LS_ERROR) << "RequestConnectedStream error: " << stream_err;
onHttpComplete(HM_CONNECT, HE_CONNECT_FAILED);
@@ -453,7 +459,7 @@ bool HttpClient::ShouldRedirect(std::string* location) const {
}
bool HttpClient::BeginCacheFile() {
- RTC_DCHECK(NULL != cache_);
+ RTC_DCHECK(nullptr != cache_);
RTC_DCHECK(CS_READY == cache_state_);
std::string id = GetCacheID(request());
@@ -494,7 +500,7 @@ HttpError HttpClient::WriteCacheHeaders(const std::string& id) {
return HE_CACHE;
}
- if (!HttpWriteCacheHeaders(&transaction_->response, stream.get(), NULL)) {
+ if (!HttpWriteCacheHeaders(&transaction_->response, stream.get(), nullptr)) {
LOG_F(LS_ERROR) << "Couldn't write header cache";
return HE_CACHE;
}
@@ -520,7 +526,7 @@ void HttpClient::CompleteCacheFile() {
}
bool HttpClient::CheckCache() {
- RTC_DCHECK(NULL != cache_);
+ RTC_DCHECK(nullptr != cache_);
RTC_DCHECK(CS_READY == cache_state_);
std::string id = GetCacheID(request());
@@ -691,9 +697,9 @@ HttpError HttpClient::onHttpHeaderComplete(bool chunked, size_t& data_size) {
// HEAD requests and certain response codes contain no body
data_size = 0;
}
- if (ShouldRedirect(NULL)
- || ((HC_PROXY_AUTHENTICATION_REQUIRED == response().scode)
- && (PROXY_HTTPS == proxy_.type))) {
+ if (ShouldRedirect(nullptr) ||
+ ((HC_PROXY_AUTHENTICATION_REQUIRED == response().scode) &&
+ (PROXY_HTTPS == proxy_.type))) {
// We're going to issue another request, so ignore the incoming data.
base_.set_ignore_data(true);
}
@@ -703,9 +709,8 @@ HttpError HttpClient::onHttpHeaderComplete(bool chunked, size_t& data_size) {
return error;
}
- if ((NULL != cache_)
- && !base_.ignore_data()
- && HttpShouldCache(*transaction_)) {
+ if ((nullptr != cache_) && !base_.ignore_data() &&
+ HttpShouldCache(*transaction_)) {
if (BeginCacheFile()) {
cache_state_ = CS_WRITING;
}
@@ -827,7 +832,7 @@ HttpClientDefault::HttpClientDefault(SocketFactory* factory,
const std::string& agent,
HttpTransaction* transaction)
: ReuseSocketPool(factory ? factory : Thread::Current()->socketserver()),
- HttpClient(agent, NULL, transaction) {
+ HttpClient(agent, nullptr, transaction) {
set_pool(this);
}

Powered by Google App Engine
This is Rietveld 408576698