Commit 514272fc authored by kmarshall's avatar kmarshall Committed by Commit bot

Replace NULL with nullptr.

BUG=

Review URL: https://codereview.chromium.org/843453002

Cr-Commit-Position: refs/heads/master@{#313382}
parent 6c29e387
......@@ -160,7 +160,7 @@ scoped_ptr<base::Timer> CastChannelAPI::GetInjectedTimeoutTimerForTest() {
CastChannelAPI::~CastChannelAPI() {}
CastChannelAsyncApiFunction::CastChannelAsyncApiFunction() : manager_(NULL) {
CastChannelAsyncApiFunction::CastChannelAsyncApiFunction() : manager_(nullptr) {
}
CastChannelAsyncApiFunction::~CastChannelAsyncApiFunction() { }
......
......@@ -59,7 +59,7 @@ class CastChannelAPI : public BrowserContextKeyedAPI {
void SetSocketForTest(scoped_ptr<cast_channel::CastSocket> socket_for_test);
// Returns a test CastSocket instance, if it is defined.
// Otherwise returns a scoped_ptr with a NULL ptr value.
// Otherwise returns a scoped_ptr with a nullptr value.
scoped_ptr<cast_channel::CastSocket> GetSocketForTest();
// Returns the API browser context.
......@@ -176,7 +176,7 @@ class CastChannelOpenFunction : public CastChannelAsyncApiFunction {
cast_channel::ConnectInfo* connect_info);
// Validates that |connect_info| represents a valid IP end point and returns a
// new IPEndPoint if so. Otherwise returns NULL.
// new IPEndPoint if so. Otherwise returns nullptr.
static net::IPEndPoint* ParseConnectInfo(
const cast_channel::ConnectInfo& connect_info);
......
......@@ -58,7 +58,7 @@ TEST(CastChannelOpenFunctionTest, TestParseConnectInfo) {
connect_info.auth = CHANNEL_AUTH_TYPE_SSL;
ip_endpoint.reset(ccof::ParseConnectInfo(connect_info));
EXPECT_TRUE(ip_endpoint.get() != NULL);
EXPECT_TRUE(ip_endpoint);
EXPECT_EQ(ip_endpoint->ToString(), "192.0.0.1:8009");
}
......
......@@ -5,6 +5,8 @@
#ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_FRAMER_H_
#define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_FRAMER_H_
#include <string>
#include "base/basictypes.h"
#include "extensions/common/api/cast_channel.h"
#include "net/base/io_buffer.h"
......@@ -42,7 +44,7 @@ class MessageFramer {
// |error| The result of the ingest operation. Set to CHANNEL_ERROR_NONE
// if no error occurred.
// Returns A pointer to a parsed CastMessage if a message was received
// in its entirety, NULL otherwise.
// in its entirety, nullptr otherwise.
scoped_ptr<CastMessage> Ingest(size_t num_bytes,
size_t* message_length,
ChannelError* error);
......
......@@ -5,6 +5,7 @@
#include "extensions/browser/api/cast_channel/cast_framer.h"
#include <algorithm>
#include <string>
#include "extensions/common/api/cast_channel/cast_channel.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -50,13 +51,13 @@ TEST_F(CastFramerTest, TestMessageFramerCompleteMessage) {
// Receive 1 byte of the header, framer demands 3 more bytes.
EXPECT_EQ(4u, framer_->BytesRequested());
EXPECT_EQ(NULL, framer_->Ingest(1, &message_length, &error).get());
EXPECT_EQ(nullptr, framer_->Ingest(1, &message_length, &error).get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, error);
EXPECT_EQ(3u, framer_->BytesRequested());
// Ingest remaining 3, expect that the framer has moved on to requesting the
// body contents.
EXPECT_EQ(NULL, framer_->Ingest(3, &message_length, &error).get());
EXPECT_EQ(nullptr, framer_->Ingest(3, &message_length, &error).get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, error);
EXPECT_EQ(
cast_message_str_.size() - MessageFramer::MessageHeader::header_size(),
......@@ -65,7 +66,7 @@ TEST_F(CastFramerTest, TestMessageFramerCompleteMessage) {
// Remainder of packet sent over the wire.
scoped_ptr<CastMessage> message;
message = framer_->Ingest(framer_->BytesRequested(), &message_length, &error);
EXPECT_NE(static_cast<CastMessage*>(NULL), message.get());
EXPECT_NE(static_cast<CastMessage*>(nullptr), message.get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, error);
EXPECT_EQ(message->SerializeAsString(), cast_message_.SerializeAsString());
EXPECT_EQ(4u, framer_->BytesRequested());
......@@ -93,14 +94,14 @@ TEST_F(CastFramerTest, TestIngestIllegalLargeMessage) {
size_t bytes_ingested;
ChannelError error;
EXPECT_EQ(4u, framer_->BytesRequested());
EXPECT_EQ(NULL, framer_->Ingest(4, &bytes_ingested, &error).get());
EXPECT_EQ(nullptr, framer_->Ingest(4, &bytes_ingested, &error).get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, error);
EXPECT_EQ(0u, framer_->BytesRequested());
// Test that the parser enters a terminal error state.
WriteToBuffer(cast_message_str_);
EXPECT_EQ(0u, framer_->BytesRequested());
EXPECT_EQ(NULL, framer_->Ingest(4, &bytes_ingested, &error).get());
EXPECT_EQ(nullptr, framer_->Ingest(4, &bytes_ingested, &error).get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, error);
EXPECT_EQ(0u, framer_->BytesRequested());
}
......@@ -122,15 +123,14 @@ TEST_F(CastFramerTest, TestUnparsableBodyProto) {
size_t message_length;
ChannelError error;
EXPECT_EQ(4u, framer_->BytesRequested());
EXPECT_EQ(NULL, framer_->Ingest(4, &message_length, &error).get());
EXPECT_EQ(nullptr, framer_->Ingest(4, &message_length, &error).get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, error);
EXPECT_EQ(cast_message_str_.size() - 4, framer_->BytesRequested());
// Send body, expect an error.
scoped_ptr<CastMessage> message;
EXPECT_EQ(NULL,
framer_->Ingest(framer_->BytesRequested(), &message_length, &error)
.get());
EXPECT_EQ(nullptr, framer_->Ingest(framer_->BytesRequested(), &message_length,
&error).get());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_INVALID_MESSAGE, error);
}
} // namespace cast_channel
......
......@@ -79,13 +79,13 @@ CastMessage CreateTestMessage() {
class MockTCPSocket : public net::TCPClientSocket {
public:
explicit MockTCPSocket(const net::MockConnect& connect_data) :
TCPClientSocket(net::AddressList(), NULL, net::NetLog::Source()),
connect_data_(connect_data),
do_nothing_(false) { }
explicit MockTCPSocket(const net::MockConnect& connect_data)
: TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()),
connect_data_(connect_data),
do_nothing_(false) {}
explicit MockTCPSocket(bool do_nothing) :
TCPClientSocket(net::AddressList(), NULL, net::NetLog::Source()) {
explicit MockTCPSocket(bool do_nothing)
: TCPClientSocket(net::AddressList(), nullptr, net::NetLog::Source()) {
CHECK(do_nothing);
do_nothing_ = do_nothing;
}
......@@ -196,7 +196,7 @@ class TestCastSocket : public CastSocketImpl {
verify_challenge_disallow_(false),
tcp_unresponsive_(false),
mock_timer_(new base::MockTimer(false, false)),
mock_transport_(NULL) {}
mock_transport_(nullptr) {}
~TestCastSocket() override {}
......
......@@ -402,7 +402,7 @@ int CastTransportImpl::DoReadComplete(int result) {
}
size_t message_size;
DCHECK(current_message_.get() == NULL);
DCHECK(!current_message_);
ChannelError framing_error;
current_message_ = framer_->Ingest(result, &message_size, &framing_error);
if (current_message_.get() && (framing_error == CHANNEL_ERROR_NONE)) {
......@@ -413,11 +413,11 @@ int CastTransportImpl::DoReadComplete(int result) {
static_cast<uint32>(message_size)));
SetReadState(READ_STATE_DO_CALLBACK);
} else if (framing_error != CHANNEL_ERROR_NONE) {
DCHECK(current_message_.get() == NULL);
DCHECK(!current_message_);
SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE);
SetReadState(READ_STATE_ERROR);
} else {
DCHECK(current_message_.get() == NULL);
DCHECK(!current_message_);
SetReadState(READ_STATE_READ);
}
return net::OK;
......
......@@ -73,7 +73,7 @@ class Logger : public base::RefCounted<Logger> {
// Assembles logs collected so far and return it as a serialized Log proto,
// compressed in gzip format.
// If serialization or compression failed, returns a NULL pointer.
// If serialization or compression failed, returns nullptr.
// |length|: If successful, assigned with size of compressed content.
scoped_ptr<char[]> GetLogs(size_t* length) const;
......
......@@ -121,7 +121,7 @@ TEST_F(CastChannelLoggerTest, BasicLogging) {
EXPECT_EQ(last_errors.nss_error_code, kTestNssErrorCode);
scoped_ptr<Log> log = GetLog();
ASSERT_TRUE(log.get() != NULL);
ASSERT_TRUE(log);
ASSERT_EQ(2, log->aggregated_socket_event_size());
{
......@@ -257,7 +257,7 @@ TEST_F(CastChannelLoggerTest, LogSocketReadWrite) {
clock_->Advance(base::TimeDelta::FromMicroseconds(1));
scoped_ptr<Log> log = GetLog();
ASSERT_TRUE(log.get() != NULL);
ASSERT_TRUE(log);
ASSERT_EQ(2, log->aggregated_socket_event_size());
{
......@@ -284,7 +284,7 @@ TEST_F(CastChannelLoggerTest, TooManySockets) {
}
scoped_ptr<Log> log = GetLog();
ASSERT_TRUE(log.get() != NULL);
ASSERT_TRUE(log);
ASSERT_EQ(kMaxSocketsToLog, log->aggregated_socket_event_size());
EXPECT_EQ(5, log->num_evicted_aggregated_socket_events());
......@@ -302,7 +302,7 @@ TEST_F(CastChannelLoggerTest, TooManyEvents) {
}
scoped_ptr<Log> log = GetLog();
ASSERT_TRUE(log.get() != NULL);
ASSERT_TRUE(log);
ASSERT_EQ(1, log->aggregated_socket_event_size());
EXPECT_EQ(0, log->num_evicted_aggregated_socket_events());
......@@ -318,14 +318,14 @@ TEST_F(CastChannelLoggerTest, Reset) {
logger_->LogSocketEvent(1, EventType::CAST_SOCKET_CREATED);
scoped_ptr<Log> log = GetLog();
ASSERT_TRUE(log.get() != NULL);
ASSERT_TRUE(log);
EXPECT_EQ(1, log->aggregated_socket_event_size());
logger_->Reset();
log = GetLog();
ASSERT_TRUE(log.get() != NULL);
ASSERT_TRUE(log);
EXPECT_EQ(0, log->aggregated_socket_event_size());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment