Commit 38450201 authored by viettrungluu's avatar viettrungluu Committed by Commit bot

Mojo: NULL -> nullptr in mojo/public/cpp outside of bindings.

R=jamesr@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#297329}
parent 89949e66
......@@ -5,8 +5,6 @@
#ifndef MOJO_PUBLIC_CPP_APPLICATION_LAZY_INTERFACE_PTR_H_
#define MOJO_PUBLIC_CPP_APPLICATION_LAZY_INTERFACE_PTR_H_
#include <string>
#include "mojo/public/cpp/application/connect.h"
#include "mojo/public/interfaces/application/service_provider.mojom.h"
......@@ -15,7 +13,7 @@ namespace mojo {
template<typename Interface>
class LazyInterfacePtr : public InterfacePtr<Interface> {
public:
LazyInterfacePtr() : service_provider_(NULL) {}
LazyInterfacePtr() : service_provider_(nullptr) {}
LazyInterfacePtr(ServiceProvider* service_provider)
: service_provider_(service_provider) {
......
......@@ -27,13 +27,13 @@ class ApplicationImpl::ShellPtrWatcher : public ErrorHandler {
ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
ScopedMessagePipeHandle shell_handle)
: initialized_(false), delegate_(delegate), shell_watch_(NULL) {
: initialized_(false), delegate_(delegate), shell_watch_(nullptr) {
BindShell(shell_handle.Pass());
}
ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
MojoHandle shell_handle)
: initialized_(false), delegate_(delegate), shell_watch_(NULL) {
: initialized_(false), delegate_(delegate), shell_watch_(nullptr) {
BindShell(MakeScopedHandle(MessagePipeHandle(shell_handle)));
}
......@@ -71,7 +71,7 @@ ApplicationConnection* ApplicationImpl::ConnectToApplication(
out_service_provider.Pass());
if (!delegate_->ConfigureOutgoingConnection(registry)) {
delete registry;
return NULL;
return nullptr;
}
outgoing_service_registries_.push_back(registry);
return registry;
......
......@@ -30,7 +30,7 @@ MojoResult ApplicationRunner::Run(MojoHandle shell_handle) {
}
delete delegate_;
delegate_ = NULL;
delegate_ = nullptr;
return MOJO_RESULT_OK;
}
......
......@@ -9,7 +9,7 @@ namespace internal {
ServiceConnectorBase::ServiceConnectorBase(const std::string& name)
: name_(name),
application_connection_(NULL) {
application_connection_(nullptr) {
}
ServiceConnectorBase::~ServiceConnectorBase() {}
......
......@@ -10,7 +10,7 @@
namespace mojo {
ServiceProviderImpl::ServiceProviderImpl() : remote_(NULL) {
ServiceProviderImpl::ServiceProviderImpl() : remote_(nullptr) {
}
ServiceProviderImpl::~ServiceProviderImpl() {
......@@ -46,7 +46,7 @@ void ServiceProviderImpl::AddServiceConnector(
RemoveServiceConnector(service_connector);
service_connectors_[service_connector->name()] = service_connector;
// TODO(beng): perhaps take app connection thru ctor??
service_connector->set_application_connection(NULL);
service_connector->set_application_connection(nullptr);
}
void ServiceProviderImpl::RemoveServiceConnector(
......@@ -62,7 +62,7 @@ void ServiceProviderImpl::RemoveServiceConnector(
void ServiceProviderImpl::ClearRemote() {
if (remote_) {
remote_->Clear();
remote_ = NULL;
remote_ = nullptr;
}
}
......
......@@ -20,7 +20,7 @@ ServiceRegistry::ServiceRegistry(ApplicationImpl* application_impl,
remote_service_provider_.set_client(this);
}
ServiceRegistry::ServiceRegistry() : application_impl_(NULL) {}
ServiceRegistry::ServiceRegistry() : application_impl_(nullptr) {}
ServiceRegistry::~ServiceRegistry() {
for (NameToServiceConnectorMap::iterator i =
......
......@@ -21,8 +21,8 @@ WeakServiceProvider::~WeakServiceProvider() {
}
void WeakServiceProvider::Clear() {
creator_ = NULL;
service_provider_ = NULL;
creator_ = nullptr;
service_provider_ = nullptr;
}
void WeakServiceProvider::ConnectToService(
......
......@@ -5,7 +5,6 @@
#include "mojo/public/cpp/environment/environment.h"
#include <assert.h>
#include <stddef.h>
#include "mojo/public/c/environment/logger.h"
#include "mojo/public/cpp/environment/lib/default_async_waiter.h"
......@@ -16,8 +15,8 @@ namespace mojo {
namespace {
const MojoAsyncWaiter* g_default_async_waiter = NULL;
const MojoLogger* g_default_logger = NULL;
const MojoAsyncWaiter* g_default_async_waiter = nullptr;
const MojoLogger* g_default_logger = nullptr;
void Init(const MojoAsyncWaiter* default_async_waiter,
const MojoLogger* default_logger) {
......@@ -33,7 +32,7 @@ void Init(const MojoAsyncWaiter* default_async_waiter,
} // namespace
Environment::Environment() {
Init(NULL, NULL);
Init(nullptr, nullptr);
}
Environment::Environment(const MojoAsyncWaiter* default_async_waiter,
......@@ -46,8 +45,8 @@ Environment::~Environment() {
// TODO(vtl): Maybe we should allow nesting, and restore previous default
// async waiters and loggers?
g_default_async_waiter = NULL;
g_default_logger = NULL;
g_default_async_waiter = nullptr;
g_default_logger = nullptr;
}
// static
......
......@@ -31,7 +31,7 @@ bool DcheckTestHelper(bool* was_called) {
class LoggingTest : public testing::Test {
public:
LoggingTest() : environment_(NULL, &kMockLogger) {
LoggingTest() : environment_(nullptr, &kMockLogger) {
minimum_log_level_ = MOJO_LOG_LEVEL_INFO;
ResetMockLogger();
}
......
......@@ -93,7 +93,7 @@ class SharedBuffer {
inline SharedBuffer::SharedBuffer(uint64_t num_bytes) {
MojoResult result MOJO_ALLOW_UNUSED =
CreateSharedBuffer(NULL, num_bytes, &handle);
CreateSharedBuffer(nullptr, num_bytes, &handle);
assert(result == MOJO_RESULT_OK);
}
......
......@@ -120,7 +120,7 @@ class DataPipe {
inline DataPipe::DataPipe() {
MojoResult result MOJO_ALLOW_UNUSED =
CreateDataPipe(NULL, &producer_handle, &consumer_handle);
CreateDataPipe(nullptr, &producer_handle, &consumer_handle);
assert(result == MOJO_RESULT_OK);
}
......
......@@ -214,7 +214,7 @@ inline MojoResult WaitMany(const HandleVectorType& handles,
return MOJO_RESULT_OUT_OF_RANGE;
if (handles.size() == 0)
return MojoWaitMany(NULL, NULL, 0, deadline);
return MojoWaitMany(nullptr, nullptr, 0, deadline);
const Handle& first_handle = handles[0];
const MojoHandleSignals& first_signals = signals[0];
......
......@@ -85,7 +85,7 @@ class MessagePipe {
inline MessagePipe::MessagePipe() {
MojoResult result MOJO_ALLOW_UNUSED =
CreateMessagePipe(NULL, &handle0, &handle1);
CreateMessagePipe(nullptr, &handle0, &handle1);
assert(result == MOJO_RESULT_OK);
}
......
......@@ -124,25 +124,25 @@ TEST(CoreCppTest, Basic) {
EXPECT_FALSE(h_invalid.is_valid());
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
WriteMessageRaw(h_invalid,
NULL, 0,
NULL, 0,
nullptr, 0,
nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
char buffer[10] = { 0 };
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
WriteMessageRaw(h_invalid,
buffer, sizeof(buffer),
NULL, 0,
nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
ReadMessageRaw(h_invalid,
NULL, NULL,
NULL, NULL,
nullptr, nullptr,
nullptr, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
ReadMessageRaw(h_invalid,
buffer, &buffer_size,
NULL, NULL,
nullptr, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
// Basic tests of waiting and closing.
......@@ -153,7 +153,7 @@ TEST(CoreCppTest, Basic) {
EXPECT_FALSE(h0.get().is_valid());
EXPECT_FALSE(h1.get().is_valid());
CreateMessagePipe(NULL, &h0, &h1);
CreateMessagePipe(nullptr, &h0, &h1);
EXPECT_TRUE(h0.get().is_valid());
EXPECT_TRUE(h1.get().is_valid());
EXPECT_NE(h0.get().value(), h1.get().value());
......@@ -193,14 +193,14 @@ TEST(CoreCppTest, Basic) {
{
ScopedMessagePipeHandle h0;
ScopedMessagePipeHandle h1;
CreateMessagePipe(NULL, &h0, &h1);
CreateMessagePipe(nullptr, &h0, &h1);
const char kHello[] = "hello";
const uint32_t kHelloSize = static_cast<uint32_t>(sizeof(kHello));
EXPECT_EQ(MOJO_RESULT_OK,
WriteMessageRaw(h0.get(),
kHello, kHelloSize,
NULL, 0,
nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
EXPECT_EQ(MOJO_RESULT_OK,
Wait(h1.get(), MOJO_HANDLE_SIGNAL_READABLE,
......@@ -210,7 +210,7 @@ TEST(CoreCppTest, Basic) {
EXPECT_EQ(MOJO_RESULT_OK,
ReadMessageRaw(h1.get(),
buffer, &buffer_size,
NULL, NULL,
nullptr, nullptr,
MOJO_READ_MESSAGE_FLAG_NONE));
EXPECT_EQ(kHelloSize, buffer_size);
EXPECT_STREQ(kHello, buffer);
......@@ -226,7 +226,7 @@ TEST(CoreCppTest, Basic) {
EXPECT_EQ(MOJO_RESULT_OK,
WriteMessageRaw(mp.handle0.get(),
kWorld, kWorldSize,
NULL, 0,
nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Send |mp.handle1| over |h1| to |h0|.
......@@ -296,12 +296,12 @@ TEST(CoreCppTest, TearDownWithMessagesEnqueued) {
{
ScopedMessagePipeHandle h0;
ScopedMessagePipeHandle h1;
CreateMessagePipe(NULL, &h0, &h1);
CreateMessagePipe(nullptr, &h0, &h1);
// Send a handle over the previously-establish message pipe.
ScopedMessagePipeHandle h2;
ScopedMessagePipeHandle h3;
CreateMessagePipe(NULL, &h2, &h3);
CreateMessagePipe(nullptr, &h2, &h3);
// Write a message to |h2|, before we send |h3|.
const char kWorld[] = "world!";
......@@ -309,13 +309,13 @@ TEST(CoreCppTest, TearDownWithMessagesEnqueued) {
EXPECT_EQ(MOJO_RESULT_OK,
WriteMessageRaw(h2.get(),
kWorld, kWorldSize,
NULL, 0,
nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// And also a message to |h3|.
EXPECT_EQ(MOJO_RESULT_OK,
WriteMessageRaw(h3.get(),
kWorld, kWorldSize,
NULL, 0,
nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Send |h3| over |h1| to |h0|.
......@@ -343,12 +343,12 @@ TEST(CoreCppTest, TearDownWithMessagesEnqueued) {
{
ScopedMessagePipeHandle h0;
ScopedMessagePipeHandle h1;
CreateMessagePipe(NULL, &h0, &h1);
CreateMessagePipe(nullptr, &h0, &h1);
// Send a handle over the previously-establish message pipe.
ScopedMessagePipeHandle h2;
ScopedMessagePipeHandle h3;
CreateMessagePipe(NULL, &h2, &h3);
CreateMessagePipe(nullptr, &h2, &h3);
// Write a message to |h2|, before we send |h3|.
const char kWorld[] = "world!";
......@@ -356,13 +356,13 @@ TEST(CoreCppTest, TearDownWithMessagesEnqueued) {
EXPECT_EQ(MOJO_RESULT_OK,
WriteMessageRaw(h2.get(),
kWorld, kWorldSize,
NULL, 0,
nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// And also a message to |h3|.
EXPECT_EQ(MOJO_RESULT_OK,
WriteMessageRaw(h3.get(),
kWorld, kWorldSize,
NULL, 0,
nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE));
// Send |h3| over |h1| to |h0|.
......@@ -388,11 +388,11 @@ TEST(CoreCppTest, TearDownWithMessagesEnqueued) {
TEST(CoreCppTest, ScopedHandleMoveCtor) {
ScopedSharedBufferHandle buffer1;
EXPECT_EQ(MOJO_RESULT_OK, CreateSharedBuffer(NULL, 1024, &buffer1));
EXPECT_EQ(MOJO_RESULT_OK, CreateSharedBuffer(nullptr, 1024, &buffer1));
EXPECT_TRUE(buffer1.is_valid());
ScopedSharedBufferHandle buffer2;
EXPECT_EQ(MOJO_RESULT_OK, CreateSharedBuffer(NULL, 1024, &buffer2));
EXPECT_EQ(MOJO_RESULT_OK, CreateSharedBuffer(nullptr, 1024, &buffer2));
EXPECT_TRUE(buffer2.is_valid());
// If this fails to close buffer1, ScopedHandleBase::CloseIfNecessary() will
......@@ -405,7 +405,7 @@ TEST(CoreCppTest, ScopedHandleMoveCtor) {
TEST(CoreCppTest, ScopedHandleMoveCtorSelf) {
ScopedSharedBufferHandle buffer1;
EXPECT_EQ(MOJO_RESULT_OK, CreateSharedBuffer(NULL, 1024, &buffer1));
EXPECT_EQ(MOJO_RESULT_OK, CreateSharedBuffer(nullptr, 1024, &buffer1));
EXPECT_TRUE(buffer1.is_valid());
buffer1 = buffer1.Pass();
......
......@@ -14,7 +14,7 @@ std::vector<std::string> EnumerateSourceRootRelativeDirectory(
char** names = MojoTestSupportEnumerateSourceRootRelativeDirectory(
relative_path.c_str());
std::vector<std::string> results;
for (char** ptr = names; *ptr != NULL; ++ptr) {
for (char** ptr = names; *ptr != nullptr; ++ptr) {
results.push_back(*ptr);
free(*ptr);
}
......
......@@ -15,7 +15,7 @@ bool WriteTextMessage(const MessagePipeHandle& handle,
MojoResult rv = WriteMessageRaw(handle,
text.data(),
static_cast<uint32_t>(text.size()),
NULL,
nullptr,
0,
MOJO_WRITE_MESSAGE_FLAG_NONE);
return rv == MOJO_RESULT_OK;
......@@ -28,9 +28,9 @@ bool ReadTextMessage(const MessagePipeHandle& handle, std::string* text) {
uint32_t num_bytes = 0, num_handles = 0;
for (;;) {
rv = ReadMessageRaw(handle,
NULL,
nullptr,
&num_bytes,
NULL,
nullptr,
&num_handles,
MOJO_READ_MESSAGE_FLAG_NONE);
if (rv == MOJO_RESULT_SHOULD_WAIT) {
......@@ -52,14 +52,14 @@ bool ReadTextMessage(const MessagePipeHandle& handle, std::string* text) {
rv = ReadMessageRaw(handle,
&text->at(0),
&num_bytes,
NULL,
nullptr,
&num_handles,
MOJO_READ_MESSAGE_FLAG_NONE);
return rv == MOJO_RESULT_OK;
}
bool DiscardMessage(const MessagePipeHandle& handle) {
MojoResult rv = ReadMessageRaw(handle, NULL, NULL, NULL, NULL,
MojoResult rv = ReadMessageRaw(handle, nullptr, nullptr, nullptr, nullptr,
MOJO_READ_MESSAGE_FLAG_MAY_DISCARD);
return rv == MOJO_RESULT_OK;
}
......
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