summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 23:19:33 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 23:19:33 +0000
commitb1f031ddf0723e5a4811bf9fa6fdda68c97633de (patch)
tree81be42f2b7c8cbf8e2bb5aaea1f1b1a6213413ca /net
parent136ba26595ceafeb57a5c4d524caf7f87b95daf3 (diff)
downloadchromium_src-b1f031ddf0723e5a4811bf9fa6fdda68c97633de.zip
chromium_src-b1f031ddf0723e5a4811bf9fa6fdda68c97633de.tar.gz
chromium_src-b1f031ddf0723e5a4811bf9fa6fdda68c97633de.tar.bz2
Use CHECK_* in net
Review URL: http://codereview.chromium.org/660404 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/host_resolver_impl.cc6
-rw-r--r--net/base/mock_host_resolver.cc2
-rw-r--r--net/base/network_change_notifier_win.cc2
-rw-r--r--net/base/sdch_filter_unittest.cc20
-rw-r--r--net/base/upload_data_stream.cc3
-rw-r--r--net/disk_cache/stress_cache.cc3
-rw-r--r--net/http/http_stream_parser.cc6
-rw-r--r--net/proxy/proxy_config_service_linux.cc4
-rw-r--r--net/socket/client_socket_handle.cc2
-rw-r--r--net/socket/client_socket_pool_base.cc6
-rw-r--r--net/socket/tcp_client_socket_unittest.cc2
-rw-r--r--net/socket/tcp_client_socket_win.cc12
-rw-r--r--net/spdy/spdy_network_transaction.cc2
-rw-r--r--net/spdy/spdy_session.cc8
-rw-r--r--net/spdy/spdy_stream.cc18
-rw-r--r--net/tools/flip_server/balsa_headers.cc1
16 files changed, 48 insertions, 49 deletions
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 184324b..6af3079 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -442,7 +442,7 @@ class HostResolverImpl::JobPool {
// specific meaning of these parameters.
void SetConstraints(size_t max_outstanding_jobs,
size_t max_pending_requests) {
- CHECK(max_outstanding_jobs != 0u);
+ CHECK_NE(max_outstanding_jobs, 0u);
max_outstanding_jobs_ = max_outstanding_jobs;
max_pending_requests_ = max_pending_requests;
}
@@ -816,8 +816,8 @@ scoped_refptr<LoadLog> HostResolverImpl::GetRequestsTrace() {
void HostResolverImpl::SetPoolConstraints(JobPoolIndex pool_index,
size_t max_outstanding_jobs,
size_t max_pending_requests) {
- CHECK(pool_index >= 0);
- CHECK(pool_index < POOL_COUNT);
+ CHECK_GE(pool_index, 0);
+ CHECK_LT(pool_index, POOL_COUNT);
CHECK(jobs_.empty()) << "Can only set constraints during setup";
JobPool* pool = job_pools_[pool_index];
pool->SetConstraints(max_outstanding_jobs, max_pending_requests);
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index 9a2c916..239275e 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -224,7 +224,7 @@ ScopedDefaultHostResolverProc::ScopedDefaultHostResolverProc(
ScopedDefaultHostResolverProc::~ScopedDefaultHostResolverProc() {
HostResolverProc* old_proc = HostResolverProc::SetDefault(previous_proc_);
// The lifetimes of multiple instances must be nested.
- CHECK(old_proc == current_proc_);
+ CHECK_EQ(old_proc, current_proc_);
}
void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) {
diff --git a/net/base/network_change_notifier_win.cc b/net/base/network_change_notifier_win.cc
index d139eb0f..8ae39fb 100644
--- a/net/base/network_change_notifier_win.cc
+++ b/net/base/network_change_notifier_win.cc
@@ -51,7 +51,7 @@ NetworkChangeNotifierWin::Impl::~Impl() {
void NetworkChangeNotifierWin::Impl::WatchForAddressChange() {
HANDLE handle = NULL;
DWORD ret = NotifyAddrChange(&handle, &addr_overlapped_);
- CHECK(ret == ERROR_IO_PENDING);
+ CHECK_EQ(ERROR_IO_PENDING, ret);
addr_watcher_.StartWatching(addr_overlapped_.hEvent, this);
}
diff --git a/net/base/sdch_filter_unittest.cc b/net/base/sdch_filter_unittest.cc
index 99a3ffd..675a135 100644
--- a/net/base/sdch_filter_unittest.cc
+++ b/net/base/sdch_filter_unittest.cc
@@ -111,7 +111,7 @@ static bool FilterTestData(const std::string& source,
size_t input_block_length,
const size_t output_buffer_length,
Filter* filter, std::string* output) {
- CHECK(input_block_length > 0);
+ CHECK_GT(input_block_length, 0u);
Filter::FilterStatus status(Filter::FILTER_NEED_MORE_DATA);
size_t source_index = 0;
scoped_array<char> output_buffer(new char[output_buffer_length]);
@@ -375,8 +375,8 @@ TEST_F(SdchFilterTest, BasicBadDictionary) {
// list of dictionaries, so the filter should error out immediately.
std::string dictionary_hash_postfix("4abcd\0", 6);
- CHECK(dictionary_hash_postfix.size() <
- static_cast<size_t>(input_buffer_size));
+ CHECK_LT(dictionary_hash_postfix.size(),
+ static_cast<size_t>(input_buffer_size));
memcpy(input_buffer, dictionary_hash_postfix.data(),
dictionary_hash_postfix.size());
filter->FlushStreamBuffer(dictionary_hash_postfix.size());
@@ -792,7 +792,7 @@ static std::string gzip_compress(const std::string &input) {
8, // DEF_MEM_LEVEL
Z_DEFAULT_STRATEGY);
- CHECK(code == Z_OK);
+ CHECK_EQ(Z_OK, code);
// Fill in zlib control block
zlib_stream.next_in = bit_cast<Bytef*>(input.data());
@@ -819,7 +819,7 @@ static std::string gzip_compress(const std::string &input) {
// Header value we generate:
const char kGZipHeader[] = { '\037', '\213', '\010', '\000', '\000',
'\000', '\000', '\000', '\002', '\377' };
- CHECK(zlib_stream.avail_out > sizeof(kGZipHeader));
+ CHECK_GT(zlib_stream.avail_out, sizeof(kGZipHeader));
memcpy(zlib_stream.next_out, kGZipHeader, sizeof(kGZipHeader));
zlib_stream.next_out += sizeof(kGZipHeader);
zlib_stream.avail_out -= sizeof(kGZipHeader);
@@ -860,9 +860,9 @@ TEST_F(SdchFilterTest, FilterChaining) {
// First try with a large buffer (larger than test input, or compressed data).
const size_t kLargeInputBufferSize(1000); // Used internally in filters.
- CHECK(kLargeInputBufferSize > gzip_compressed_sdch.size());
- CHECK(kLargeInputBufferSize > sdch_compressed.size());
- CHECK(kLargeInputBufferSize > expanded_.size());
+ CHECK_GT(kLargeInputBufferSize, gzip_compressed_sdch.size());
+ CHECK_GT(kLargeInputBufferSize, sdch_compressed.size());
+ CHECK_GT(kLargeInputBufferSize, expanded_.size());
MockFilterContext filter_context(kLargeInputBufferSize);
filter_context.SetURL(url);
scoped_ptr<Filter> filter(Filter::Factory(filter_types, filter_context));
@@ -884,11 +884,11 @@ TEST_F(SdchFilterTest, FilterChaining) {
// Next try with a mid-sized internal buffer size.
const size_t kMidSizedInputBufferSize(100);
// Buffer should be big enough to swallow whole gzip content.
- CHECK(kMidSizedInputBufferSize > gzip_compressed_sdch.size());
+ CHECK_GT(kMidSizedInputBufferSize, gzip_compressed_sdch.size());
// Buffer should be small enough that entire SDCH content can't fit.
// We'll go even further, and force the chain to flush the buffer between the
// two filters more than once (that is why we multiply by 2).
- CHECK(kMidSizedInputBufferSize * 2 < sdch_compressed.size());
+ CHECK_LT(kMidSizedInputBufferSize * 2, sdch_compressed.size());
filter_context.SetBufferSize(kMidSizedInputBufferSize);
filter_context.SetURL(url);
filter.reset(Filter::Factory(filter_types, filter_context));
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc
index 221ef28..21f4ce8 100644
--- a/net/base/upload_data_stream.cc
+++ b/net/base/upload_data_stream.cc
@@ -27,8 +27,7 @@ UploadDataStream::~UploadDataStream() {
}
void UploadDataStream::DidConsume(size_t num_bytes) {
- // TODO(vandebo): Change back to a DCHECK when issue 27870 is resolved.
- CHECK(num_bytes <= buf_len_);
+ DCHECK_LE(num_bytes, buf_len_);
DCHECK(!eof_);
buf_len_ -= num_bytes;
diff --git a/net/disk_cache/stress_cache.cc b/net/disk_cache/stress_cache.cc
index 67c396c..3619a5f 100644
--- a/net/disk_cache/stress_cache.cc
+++ b/net/disk_cache/stress_cache.cc
@@ -115,7 +115,8 @@ void StressTheCache(int iteration) {
CHECK(cache->CreateEntry(keys[key], &entries[slot]));
base::snprintf(buffer->data(), kSize, "%d %d", iteration, i);
- CHECK(kSize == entries[slot]->WriteData(0, 0, buffer, kSize, NULL, false));
+ CHECK_EQ(kSize,
+ entries[slot]->WriteData(0, 0, buffer, kSize, NULL, false));
if (rand() % 100 > 80) {
key = rand() % kNumKeys;
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 02b09f0..3633af3 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -310,7 +310,7 @@ int HttpStreamParser::DoReadHeadersComplete(int result) {
io_state_ = STATE_DONE;
int extra_bytes = read_buf_->offset() - read_buf_unused_offset_;
if (extra_bytes) {
- CHECK(extra_bytes > 0);
+ CHECK_GT(extra_bytes, 0);
memmove(read_buf_->StartOfBuffer(),
read_buf_->StartOfBuffer() + read_buf_unused_offset_,
extra_bytes);
@@ -331,7 +331,7 @@ int HttpStreamParser::DoReadBody() {
if (read_buf_->offset()) {
int available = read_buf_->offset() - read_buf_unused_offset_;
if (available) {
- CHECK(available > 0);
+ CHECK_GT(available, 0);
int bytes_from_buffer = std::min(available, user_read_buf_len_);
memcpy(user_read_buf_->data(),
read_buf_->StartOfBuffer() + read_buf_unused_offset_,
@@ -396,7 +396,7 @@ int HttpStreamParser::DoReadBodyComplete(int result) {
}
}
- CHECK(save_amount + additional_save_amount <= kMaxBufSize);
+ CHECK_LE(save_amount + additional_save_amount, kMaxBufSize);
if (read_buf_->capacity() < save_amount + additional_save_amount) {
read_buf_->SetCapacity(save_amount + additional_save_amount);
}
diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc
index 795c644..c1d18dd 100644
--- a/net/proxy/proxy_config_service_linux.cc
+++ b/net/proxy/proxy_config_service_linux.cc
@@ -751,8 +751,8 @@ class GConfSettingGetterImplKDE
while (event_ptr < event_buf + r) {
inotify_event* event = reinterpret_cast<inotify_event*>(event_ptr);
// The kernel always feeds us whole events.
- CHECK(event_ptr + sizeof(inotify_event) <= event_buf + r);
- CHECK(event->name + event->len <= event_buf + r);
+ CHECK_LE(event_ptr + sizeof(inotify_event), event_buf + r);
+ CHECK_LE(event->name + event->len, event_buf + r);
if (!strcmp(event->name, "kioslaverc"))
kioslaverc_touched = true;
// Advance the pointer just past the end of the filename.
diff --git a/net/socket/client_socket_handle.cc b/net/socket/client_socket_handle.cc
index d283dd6..8db0543 100644
--- a/net/socket/client_socket_handle.cc
+++ b/net/socket/client_socket_handle.cc
@@ -59,7 +59,7 @@ void ClientSocketHandle::OnIOComplete(int result) {
}
void ClientSocketHandle::HandleInitCompletion(int result) {
- CHECK(ERR_IO_PENDING != result);
+ CHECK_NE(ERR_IO_PENDING, result);
if (result != OK)
ResetInternal(false); // The request failed, so there's nothing to cancel.
}
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index c6d9493..52b31a6 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -400,10 +400,10 @@ void ClientSocketPoolBaseHelper::DoReleaseSocket(const std::string& group_name,
group.num_releasing_sockets--;
DCHECK_GE(group.num_releasing_sockets, 0);
- CHECK(handed_out_socket_count_ > 0);
+ CHECK_GT(handed_out_socket_count_, 0);
handed_out_socket_count_--;
- CHECK(group.active_socket_count > 0);
+ CHECK_GT(group.active_socket_count, 0);
group.active_socket_count--;
const bool can_reuse = socket->IsConnectedAndIdle();
@@ -527,7 +527,7 @@ void ClientSocketPoolBaseHelper::OnIPAddressChanged() {
void ClientSocketPoolBaseHelper::RemoveConnectJob(const ConnectJob *job,
Group* group) {
- CHECK(connecting_socket_count_ > 0);
+ CHECK_GT(connecting_socket_count_, 0);
connecting_socket_count_--;
DCHECK(job);
diff --git a/net/socket/tcp_client_socket_unittest.cc b/net/socket/tcp_client_socket_unittest.cc
index e1e08ab..ffbde90 100644
--- a/net/socket/tcp_client_socket_unittest.cc
+++ b/net/socket/tcp_client_socket_unittest.cc
@@ -91,7 +91,7 @@ void TCPClientSocketTest::SetUp() {
scoped_refptr<HostResolver> resolver(CreateSystemHostResolver(NULL));
HostResolver::RequestInfo info("localhost", listen_port_);
int rv = resolver->Resolve(info, &addr, NULL, NULL, NULL);
- CHECK(rv == OK);
+ CHECK_EQ(rv, OK);
sock_.reset(new TCPClientSocket(addr));
}
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index 1ec8b28..b1270bb 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -35,7 +35,7 @@ bool ResetEventIfSignaled(WSAEVENT hEvent) {
DWORD wait_rv = WaitForSingleObject(hEvent, 0);
if (wait_rv == WAIT_TIMEOUT)
return false; // The event object is not signaled.
- CHECK(wait_rv == WAIT_OBJECT_0);
+ CHECK_EQ(WAIT_OBJECT_0, wait_rv);
BOOL ok = WSAResetEvent(hEvent);
CHECK(ok);
return true;
@@ -459,7 +459,8 @@ int TCPClientSocketWin::Read(IOBuffer* buf,
TRACE_EVENT_BEGIN("socket.read", this, "");
// TODO(wtc): Remove the CHECK after enough testing.
- CHECK(WaitForSingleObject(core_->read_overlapped_.hEvent, 0) == WAIT_TIMEOUT);
+ CHECK_EQ(WAIT_TIMEOUT,
+ WaitForSingleObject(core_->read_overlapped_.hEvent, 0));
DWORD num, flags = 0;
int rv = WSARecv(socket_, &core_->read_buffer_, 1, &num, &flags,
&core_->read_overlapped_, NULL);
@@ -496,8 +497,7 @@ int TCPClientSocketWin::Write(IOBuffer* buf,
DCHECK_NE(socket_, INVALID_SOCKET);
DCHECK(!waiting_write_);
DCHECK(!write_callback_);
- //TODO(vandebo) change back to a DCHECK when 27870 is resolved
- CHECK(buf_len > 0);
+ DCHECK_GT(buf_len, 0);
DCHECK(!core_->write_iobuffer_);
static StatsCounter reads("tcp.writes");
@@ -509,8 +509,8 @@ int TCPClientSocketWin::Write(IOBuffer* buf,
TRACE_EVENT_BEGIN("socket.write", this, "");
// TODO(wtc): Remove the CHECK after enough testing.
- CHECK(
- WaitForSingleObject(core_->write_overlapped_.hEvent, 0) == WAIT_TIMEOUT);
+ CHECK_EQ(WAIT_TIMEOUT,
+ WaitForSingleObject(core_->write_overlapped_.hEvent, 0));
DWORD num;
int rv = WSASend(socket_, &core_->write_buffer_, 1, &num, 0,
&core_->write_overlapped_, NULL);
diff --git a/net/spdy/spdy_network_transaction.cc b/net/spdy/spdy_network_transaction.cc
index 3d04c1d..27e4521 100644
--- a/net/spdy/spdy_network_transaction.cc
+++ b/net/spdy/spdy_network_transaction.cc
@@ -130,7 +130,7 @@ uint64 SpdyNetworkTransaction::GetUploadProgress() const {
}
void SpdyNetworkTransaction::DoCallback(int rv) {
- CHECK(rv != ERR_IO_PENDING);
+ CHECK_NE(rv, ERR_IO_PENDING);
CHECK(user_callback_);
// Since Run may result in Read being called, clear user_callback_ up front.
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index b7887a4..aee80504 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -384,7 +384,7 @@ int SpdySession::WriteStreamData(spdy::SpdyStreamId stream_id,
// Find our stream
DCHECK(IsStreamActive(stream_id));
scoped_refptr<SpdyStream> stream = active_streams_[stream_id];
- CHECK(stream->stream_id() == stream_id);
+ CHECK_EQ(stream->stream_id(), stream_id);
if (!stream)
return ERR_INVALID_SPDY_STREAM;
@@ -890,7 +890,7 @@ void SpdySession::OnSyn(const spdy::SpdySynStreamControlFrame* frame,
if (stream) {
CHECK(stream->pushed());
- CHECK(stream->stream_id() == 0);
+ CHECK_EQ(0u, stream->stream_id());
stream->set_stream_id(stream_id);
} else {
// TODO(mbelshe): can we figure out how to use a LoadLog here?
@@ -976,7 +976,7 @@ void SpdySession::OnSynReply(const spdy::SpdySynReplyControlFrame* frame,
}
scoped_refptr<SpdyStream> stream = active_streams_[stream_id];
- CHECK(stream->stream_id() == stream_id);
+ CHECK_EQ(stream->stream_id(), stream_id);
CHECK(!stream->cancelled());
HttpResponseInfo response;
if (SpdyHeadersToHttpResponse(*headers, &response)) {
@@ -1029,7 +1029,7 @@ void SpdySession::OnFin(const spdy::SpdyRstStreamControlFrame* frame) {
return;
}
scoped_refptr<SpdyStream> stream = active_streams_[stream_id];
- CHECK(stream->stream_id() == stream_id);
+ CHECK_EQ(stream->stream_id(), stream_id);
CHECK(!stream->cancelled());
if (frame->status() == 0) {
stream->OnDataReceived(NULL, 0);
diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc
index 2517962..04865d9 100644
--- a/net/spdy/spdy_stream.cc
+++ b/net/spdy/spdy_stream.cc
@@ -63,7 +63,7 @@ int SpdyStream::ReadResponseHeaders(CompletionCallback* callback) {
// Note: The SpdyStream may have already received the response headers, so
// this call may complete synchronously.
CHECK(callback);
- CHECK(io_state_ == STATE_NONE);
+ CHECK_EQ(STATE_NONE, io_state_);
CHECK(!cancelled_);
// The SYN_REPLY has already been received.
@@ -113,7 +113,7 @@ int SpdyStream::ReadResponseBody(
CHECK(!user_callback_);
CHECK(!user_buffer_);
- CHECK(user_buffer_len_ == 0);
+ CHECK_EQ(0, user_buffer_len_);
user_callback_ = callback;
user_buffer_ = buf;
@@ -277,7 +277,7 @@ int SpdyStream::DoLoop(int result) {
switch (state) {
// State machine 1: Send headers and wait for response headers.
case STATE_SEND_HEADERS:
- CHECK(result == OK);
+ CHECK_EQ(OK, result);
LoadLog::BeginEvent(load_log_,
LoadLog::TYPE_SPDY_STREAM_SEND_HEADERS);
result = DoSendHeaders();
@@ -288,7 +288,7 @@ int SpdyStream::DoLoop(int result) {
result = DoSendHeadersComplete(result);
break;
case STATE_SEND_BODY:
- CHECK(result == OK);
+ CHECK_EQ(OK, result);
LoadLog::BeginEvent(load_log_,
LoadLog::TYPE_SPDY_STREAM_SEND_BODY);
result = DoSendBody();
@@ -299,7 +299,7 @@ int SpdyStream::DoLoop(int result) {
result = DoSendBodyComplete(result);
break;
case STATE_READ_HEADERS:
- CHECK(result == OK);
+ CHECK_EQ(OK, result);
LoadLog::BeginEvent(load_log_,
LoadLog::TYPE_SPDY_STREAM_READ_HEADERS);
result = DoReadHeaders();
@@ -386,7 +386,7 @@ void SpdyStream::DoBufferedReadCallback() {
int rv = 0;
if (user_buffer_) {
rv = ReadResponseBody(user_buffer_, user_buffer_len_, user_callback_);
- CHECK(rv != ERR_IO_PENDING);
+ CHECK_NE(rv, ERR_IO_PENDING);
user_buffer_ = NULL;
user_buffer_len_ = 0;
DoCallback(rv);
@@ -394,7 +394,7 @@ void SpdyStream::DoBufferedReadCallback() {
}
void SpdyStream::DoCallback(int rv) {
- CHECK(rv != ERR_IO_PENDING);
+ CHECK_NE(rv, ERR_IO_PENDING);
CHECK(user_callback_);
// Since Run may result in being called back, clear user_callback_ in advance.
@@ -418,7 +418,7 @@ int SpdyStream::DoSendHeadersComplete(int result) {
if (result < 0)
return result;
- CHECK(result > 0);
+ CHECK_GT(result, 0);
// There is no body, skip that state.
if (!request_body_stream_.get()) {
@@ -449,7 +449,7 @@ int SpdyStream::DoSendBodyComplete(int result) {
if (result < 0)
return result;
- CHECK(result != 0);
+ CHECK_NE(result, 0);
request_body_stream_->DidConsume(result);
diff --git a/net/tools/flip_server/balsa_headers.cc b/net/tools/flip_server/balsa_headers.cc
index 40e446b..56a83a2 100644
--- a/net/tools/flip_server/balsa_headers.cc
+++ b/net/tools/flip_server/balsa_headers.cc
@@ -756,4 +756,3 @@ void BalsaHeaders::SetResponseReasonPhrase(const base::StringPiece& reason) {
}
} // namespace net
-