Modernize to C++11: NULL => nullptr.

No functional change.
This commit is contained in:
Haojian Wu 2016-07-10 11:52:28 +02:00
parent 9c74ea4bf4
commit fab02809c6
29 changed files with 82 additions and 82 deletions

View file

@ -21,7 +21,7 @@ namespace api {
Menu::Menu(v8::Isolate* isolate)
: model_(new AtomMenuModel(this)),
parent_(NULL) {
parent_(nullptr) {
}
Menu::~Menu() {

View file

@ -12,8 +12,8 @@
namespace mate {
Event::Event(v8::Isolate* isolate)
: sender_(NULL),
message_(NULL) {
: sender_(nullptr),
message_(nullptr) {
Init(isolate);
}
@ -31,8 +31,8 @@ void Event::SetSenderAndMessage(content::WebContents* sender,
}
void Event::WebContentsDestroyed() {
sender_ = NULL;
message_ = NULL;
sender_ = nullptr;
message_ = nullptr;
}
void Event::PreventDefault(v8::Isolate* isolate) {
@ -41,13 +41,13 @@ void Event::PreventDefault(v8::Isolate* isolate) {
}
bool Event::SendReply(const base::string16& json) {
if (message_ == NULL || sender_ == NULL)
if (message_ == nullptr || sender_ == nullptr)
return false;
AtomViewHostMsg_Message_Sync::WriteReplyParams(message_, json);
bool success = sender_->Send(message_);
message_ = NULL;
sender_ = NULL;
message_ = nullptr;
sender_ = nullptr;
return success;
}

View file

@ -32,7 +32,7 @@ void Erase(T* container, typename T::iterator iter) {
}
// static
AtomBrowserMainParts* AtomBrowserMainParts::self_ = NULL;
AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr;
AtomBrowserMainParts::AtomBrowserMainParts()
: fake_browser_process_(new BrowserProcess),

View file

@ -43,7 +43,7 @@ void GracefulShutdownHandler(int signal) {
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_handler = SIG_DFL;
RAW_CHECK(sigaction(signal, &action, NULL) == 0);
RAW_CHECK(sigaction(signal, &action, nullptr) == 0);
RAW_CHECK(g_pipe_pid == getpid());
RAW_CHECK(g_shutdown_pipe_write_fd != -1);
@ -171,7 +171,7 @@ void AtomBrowserMainParts::HandleSIGCHLD() {
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_handler = SIGCHLDHandler;
CHECK_EQ(sigaction(SIGCHLD, &action, NULL), 0);
CHECK_EQ(sigaction(SIGCHLD, &action, nullptr), 0);
}
void AtomBrowserMainParts::HandleShutdownSignals() {
@ -211,15 +211,15 @@ void AtomBrowserMainParts::HandleShutdownSignals() {
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_handler = SIGTERMHandler;
CHECK_EQ(sigaction(SIGTERM, &action, NULL), 0);
CHECK_EQ(sigaction(SIGTERM, &action, nullptr), 0);
// Also handle SIGINT - when the user terminates the browser via Ctrl+C. If
// the browser process is being debugged, GDB will catch the SIGINT first.
action.sa_handler = SIGINTHandler;
CHECK_EQ(sigaction(SIGINT, &action, NULL), 0);
CHECK_EQ(sigaction(SIGINT, &action, nullptr), 0);
// And SIGHUP, for when the terminal disappears. On shutdown, many Linux
// distros send SIGHUP, SIGTERM, and then SIGKILL.
action.sa_handler = SIGHUPHandler;
CHECK_EQ(sigaction(SIGHUP, &action, NULL), 0);
CHECK_EQ(sigaction(SIGHUP, &action, nullptr), 0);
}
} // namespace atom

View file

@ -183,7 +183,7 @@ bool URLRequestAsarJob::IsRedirectResponse(GURL* location,
net::Filter* URLRequestAsarJob::SetupFilter() const {
// Bug 9936 - .svgz files needs to be decompressed.
return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz")
? net::Filter::GZipFactory() : NULL;
? net::Filter::GZipFactory() : nullptr;
}
bool URLRequestAsarJob::GetMimeType(std::string* mime_type) const {
@ -338,7 +338,7 @@ void URLRequestAsarJob::DidRead(scoped_refptr<net::IOBuffer> buf, int result) {
DCHECK_GE(remaining_bytes_, 0);
}
buf = NULL;
buf = nullptr;
ReadRawDataComplete(result);
}

View file

@ -43,7 +43,7 @@ void RelauncherSynchronizeWithParent() {
struct kevent change = { 0 };
EV_SET(&change, parent_pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL);
if (kevent(kq.get(), &change, 1, NULL, 0, NULL) == -1) {
if (kevent(kq.get(), &change, 1, nullptr, 0, nullptr) == -1) {
PLOG(ERROR) << "kevent (add)";
return;
}
@ -58,7 +58,7 @@ void RelauncherSynchronizeWithParent() {
// write above to complete. The parent process is now free to exit. Wait for
// that to happen.
struct kevent event;
int events = kevent(kq.get(), NULL, 0, &event, 1, NULL);
int events = kevent(kq.get(), nullptr, 0, &event, 1, nullptr);
if (events != 1) {
if (events < 0) {
PLOG(ERROR) << "kevent (monitor)";

View file

@ -17,7 +17,7 @@ base::LazyInstance<base::ObserverList<WindowListObserver>>::Leaky
WindowList::observers_ = LAZY_INSTANCE_INITIALIZER;
// static
WindowList* WindowList::instance_ = NULL;
WindowList* WindowList::instance_ = nullptr;
// static
WindowList* WindowList::GetInstance() {

View file

@ -25,7 +25,7 @@ namespace {
struct DummyClass { bool crash; };
void Crash() {
static_cast<DummyClass*>(NULL)->crash = true;
static_cast<DummyClass*>(nullptr)->crash = true;
}
void Hang() {

View file

@ -41,7 +41,7 @@ bool GetFilesNode(const base::DictionaryValue* root,
// Test for symbol linked directory.
std::string link;
if (dir->GetStringWithoutPathExpansion("link", &link)) {
const base::DictionaryValue* linked_node = NULL;
const base::DictionaryValue* linked_node = nullptr;
if (!GetNodeFromPath(link, root, &linked_node))
return false;
dir = linked_node;
@ -60,7 +60,7 @@ bool GetChildNode(const base::DictionaryValue* root,
return true;
}
const base::DictionaryValue* files = NULL;
const base::DictionaryValue* files = nullptr;
return GetFilesNode(root, dir, &files) &&
files->GetDictionaryWithoutPathExpansion(name, out);
}
@ -78,7 +78,7 @@ bool GetNodeFromPath(std::string path,
for (size_t delimiter_position = path.find_first_of(kSeparators);
delimiter_position != std::string::npos;
delimiter_position = path.find_first_of(kSeparators)) {
const base::DictionaryValue* child = NULL;
const base::DictionaryValue* child = nullptr;
if (!GetChildNode(root, path.substr(0, delimiter_position), dir, &child))
return false;

View file

@ -162,7 +162,7 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Array(
v8::Local<v8::Array> result(v8::Array::New(isolate, val->GetSize()));
for (size_t i = 0; i < val->GetSize(); ++i) {
const base::Value* child = NULL;
const base::Value* child = nullptr;
CHECK(val->Get(i, &child));
v8::Local<v8::Value> child_v8 = ToV8ValueImpl(isolate, child);
@ -214,7 +214,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
FromV8ValueState::Level state_level(state);
if (state->HasReachedMaxRecursionDepth())
return NULL;
return nullptr;
if (val->IsNull())
return base::Value::CreateNullValue().release();
@ -235,7 +235,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
if (val->IsUndefined())
// JSON.stringify ignores undefined.
return NULL;
return nullptr;
if (val->IsDate()) {
v8::Date* date = v8::Date::Cast(*val);
@ -265,7 +265,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
if (val->IsFunction()) {
if (!function_allowed_)
// JSON.stringify refuses to convert function(){}.
return NULL;
return nullptr;
return FromV8Object(val->ToObject(), state, isolate);
}
@ -278,7 +278,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
}
LOG(ERROR) << "Unexpected v8 value type encountered.";
return NULL;
return nullptr;
}
base::Value* V8ValueConverter::FromV8Array(

View file

@ -54,7 +54,7 @@ void NodeBindingsMac::PollEvents() {
// Wait for new libuv events.
int r;
do {
r = select(fd + 1, &readset, NULL, NULL, timeout == -1 ? NULL : &tv);
r = select(fd + 1, &readset, nullptr, nullptr, timeout == -1 ? nullptr : &tv);
} while (r == -1 && errno == EINTR);
}

View file

@ -20,11 +20,11 @@ namespace {
RenderView* GetCurrentRenderView() {
WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext();
if (!frame)
return NULL;
return nullptr;
WebView* view = frame->view();
if (!view)
return NULL; // can happen during closing.
return nullptr; // can happen during closing.
return RenderView::FromWebView(view);
}
@ -33,7 +33,7 @@ void Send(mate::Arguments* args,
const base::string16& channel,
const base::ListValue& arguments) {
RenderView* render_view = GetCurrentRenderView();
if (render_view == NULL)
if (render_view == nullptr)
return;
bool success = render_view->Send(new AtomViewHostMsg_Message(
@ -49,7 +49,7 @@ base::string16 SendSync(mate::Arguments* args,
base::string16 json;
RenderView* render_view = GetCurrentRenderView();
if (render_view == NULL)
if (render_view == nullptr)
return json;
IPC::SyncMessage* message = new AtomViewHostMsg_Message_Sync(

View file

@ -7,7 +7,7 @@
#include "chrome/browser/printing/print_job_manager.h"
#include "ui/base/l10n/l10n_util.h"
BrowserProcess* g_browser_process = NULL;
BrowserProcess* g_browser_process = nullptr;
BrowserProcess::BrowserProcess() {
g_browser_process = this;
@ -16,7 +16,7 @@ BrowserProcess::BrowserProcess() {
}
BrowserProcess::~BrowserProcess() {
g_browser_process = NULL;
g_browser_process = nullptr;
}
std::string BrowserProcess::GetApplicationLocale() {

View file

@ -220,7 +220,7 @@ void NativeDesktopMediaList::Worker::Refresh(
webrtc::SharedMemory* NativeDesktopMediaList::Worker::CreateSharedMemory(
size_t size) {
return NULL;
return nullptr;
}
void NativeDesktopMediaList::Worker::OnCaptureCompleted(
@ -236,7 +236,7 @@ NativeDesktopMediaList::NativeDesktopMediaList(
update_period_(base::TimeDelta::FromMilliseconds(kDefaultUpdatePeriod)),
thumbnail_size_(100, 100),
view_dialog_id_(-1),
observer_(NULL),
observer_(nullptr),
weak_factory_(this) {
base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool();
capture_task_runner_ = worker_pool->GetSequencedTaskRunner(

View file

@ -38,7 +38,7 @@ void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner,
namespace printing {
PrintJob::PrintJob()
: source_(NULL),
: source_(nullptr),
worker_(),
settings_(),
is_job_pending_(false),
@ -106,7 +106,7 @@ void PrintJob::GetSettingsDone(const PrintSettings& new_settings,
PrintJobWorker* PrintJob::DetachWorker(PrintJobWorkerOwner* new_owner) {
NOTREACHED();
return NULL;
return nullptr;
}
const PrintSettings& PrintJob::settings() const {
@ -139,7 +139,7 @@ void PrintJob::StartPrinting() {
// Tell everyone!
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), NULL));
new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), nullptr));
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
@ -163,7 +163,7 @@ void PrintJob::Stop() {
ControlledWorkerShutdown();
} else {
// Flush the cached document.
UpdatePrintedDocument(NULL);
UpdatePrintedDocument(nullptr);
}
}
@ -183,7 +183,7 @@ void PrintJob::Cancel() {
}
// Make sure a Cancel() is broadcast.
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::FAILED, NULL, NULL));
new JobEventDetails(JobEventDetails::FAILED, nullptr, nullptr));
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
@ -207,7 +207,7 @@ bool PrintJob::FlushJob(base::TimeDelta timeout) {
}
void PrintJob::DisconnectSource() {
source_ = NULL;
source_ = nullptr;
if (document_.get())
document_->DisconnectSource();
}
@ -388,7 +388,7 @@ void PrintJob::OnDocumentDone() {
Stop();
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), NULL));
new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), nullptr));
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
@ -434,7 +434,7 @@ void PrintJob::ControlledWorkerShutdown() {
is_job_pending_ = false;
registrar_.RemoveAll();
UpdatePrintedDocument(NULL);
UpdatePrintedDocument(nullptr);
}
void PrintJob::HoldUntilStopIsCalled() {

View file

@ -41,7 +41,7 @@ scoped_refptr<PrinterQuery> PrintQueriesQueue::PopPrinterQuery(
return current_query;
}
}
return NULL;
return nullptr;
}
scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery(
@ -90,7 +90,7 @@ void PrintJobManager::Shutdown() {
StopJobs(true);
if (queue_.get())
queue_->Shutdown();
queue_ = NULL;
queue_ = nullptr;
}
void PrintJobManager::StopJobs(bool wait_for_finish) {

View file

@ -62,9 +62,9 @@ gfx::NativeView PrintingContextDelegate::GetParentView() {
content::RenderViewHost* view =
content::RenderViewHost::FromID(render_process_id_, render_view_id_);
if (!view)
return NULL;
return nullptr;
content::WebContents* wc = content::WebContents::FromRenderViewHost(view);
return wc ? wc->GetNativeView() : NULL;
return wc ? wc->GetNativeView() : nullptr;
}
std::string PrintingContextDelegate::GetAppLocale() {
@ -343,7 +343,7 @@ void PrintJobWorker::OnDocumentDone() {
base::RetainedRef(document_), nullptr));
// Makes sure the variables are reinitialized.
document_ = NULL;
document_ = nullptr;
}
void PrintJobWorker::SpoolPage(PrintedPage* page) {
@ -397,7 +397,7 @@ void PrintJobWorker::OnFailure() {
Cancel();
// Makes sure the variables are reinitialized.
document_ = NULL;
document_ = nullptr;
page_number_ = PageNumber::npos();
}

View file

@ -394,7 +394,7 @@ void PrintViewManagerBase::ReleasePrintJob() {
content::Source<PrintJob>(print_job_.get()));
print_job_->DisconnectSource();
// Don't close the worker thread.
print_job_ = NULL;
print_job_ = nullptr;
}
bool PrintViewManagerBase::RunInnerMessageLoop() {

View file

@ -122,7 +122,7 @@ bool PrinterQuery::is_callback_pending() const {
}
bool PrinterQuery::is_valid() const {
return worker_.get() != NULL;
return worker_.get() != nullptr;
}
} // namespace printing

View file

@ -246,7 +246,7 @@ content::WebContents* PrintingMessageFilter::GetWebContentsForRenderView(
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::RenderViewHost* view = content::RenderViewHost::FromID(
render_process_id_, render_view_id);
return view ? content::WebContents::FromRenderViewHost(view) : NULL;
return view ? content::WebContents::FromRenderViewHost(view) : nullptr;
}
void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) {

View file

@ -171,7 +171,7 @@ int WaitSocketForRead(int fd, const base::TimeDelta& timeout) {
FD_ZERO(&read_fds);
FD_SET(fd, &read_fds);
return HANDLE_EINTR(select(fd + 1, &read_fds, NULL, NULL, &tv));
return HANDLE_EINTR(select(fd + 1, &read_fds, nullptr, nullptr, &tv));
}
// Read a message from a socket fd, with an optional timeout.

View file

@ -26,7 +26,7 @@ PepperIsolatedFileSystemMessageFilter::Create(PP_Instance instance,
int unused_render_frame_id;
if (!host->GetRenderFrameIDsForInstance(
instance, &render_process_id, &unused_render_frame_id)) {
return NULL;
return nullptr;
}
return new PepperIsolatedFileSystemMessageFilter(
render_process_id,

View file

@ -115,10 +115,10 @@ TtsControllerImpl* TtsControllerImpl::GetInstance() {
}
TtsControllerImpl::TtsControllerImpl()
: current_utterance_(NULL),
: current_utterance_(nullptr),
paused_(false),
platform_impl_(NULL),
tts_engine_delegate_(NULL) {
platform_impl_(nullptr),
tts_engine_delegate_(nullptr) {
}
TtsControllerImpl::~TtsControllerImpl() {
@ -206,7 +206,7 @@ void TtsControllerImpl::SpeakNow(Utterance* utterance) {
if (!sends_end_event) {
utterance->Finish();
delete utterance;
current_utterance_ = NULL;
current_utterance_ = nullptr;
SpeakNextUtterance();
}
#endif
@ -222,7 +222,7 @@ void TtsControllerImpl::SpeakNow(Utterance* utterance) {
voice,
utterance->continuous_parameters());
if (!success)
current_utterance_ = NULL;
current_utterance_ = nullptr;
// If the native voice wasn't able to process this speech, see if
// the browser has built-in TTS that isn't loaded yet.
@ -323,7 +323,7 @@ void TtsControllerImpl::GetVoices(content::BrowserContext* browser_context,
}
bool TtsControllerImpl::IsSpeaking() {
return current_utterance_ != NULL || GetPlatformImpl()->IsSpeaking();
return current_utterance_ != nullptr || GetPlatformImpl()->IsSpeaking();
}
void TtsControllerImpl::FinishCurrentUtterance() {
@ -332,7 +332,7 @@ void TtsControllerImpl::FinishCurrentUtterance() {
current_utterance_->OnTtsEvent(TTS_EVENT_INTERRUPTED, kInvalidCharIndex,
std::string());
delete current_utterance_;
current_utterance_ = NULL;
current_utterance_ = nullptr;
}
}

View file

@ -195,7 +195,7 @@ void PepperFlashMenuHost::OnMenuClosed(int request_id) {
void PepperFlashMenuHost::SendMenuReply(int32_t result, int action) {
ppapi::host::ReplyMessageContext reply_context(
ppapi::proxy::ResourceMessageReplyParams(pp_resource(), 0),
NULL,
nullptr,
MSG_ROUTING_NONE);
reply_context.params.set_result(result);
host()->SendReply(reply_context, PpapiPluginMsg_FlashMenu_ShowReply(action));

View file

@ -115,7 +115,7 @@ bool IsSimpleHeader(const std::string& lower_case_header_name,
&lower_case_mime_type,
&lower_case_charset,
&had_charset,
NULL);
nullptr);
return lower_case_mime_type == "application/x-www-form-urlencoded" ||
lower_case_mime_type == "multipart/form-data" ||
lower_case_mime_type == "text/plain";

View file

@ -110,8 +110,8 @@ PrintMsg_Print_Params GetCssPrintParams(
// Invalid page size and/or margins. We just use the default setting.
if (new_content_width < 1 || new_content_height < 1) {
CHECK(frame != NULL);
page_css_params = GetCssPrintParams(NULL, page_index, page_params);
CHECK(frame != nullptr);
page_css_params = GetCssPrintParams(nullptr, page_index, page_params);
return page_css_params;
}
@ -254,7 +254,7 @@ void ComputeWebKitPrintParamsInDesiredDpi(
blink::WebPlugin* GetPlugin(const blink::WebFrame* frame) {
return frame->document().isPluginDocument() ?
frame->document().to<blink::WebPluginDocument>().plugin() : NULL;
frame->document().to<blink::WebPluginDocument>().plugin() : nullptr;
}
bool PrintingNodeOrPdfFrame(const blink::WebFrame* frame,
@ -323,7 +323,7 @@ FrameReference::FrameReference(blink::WebLocalFrame* frame) {
}
FrameReference::FrameReference() {
Reset(NULL);
Reset(nullptr);
}
FrameReference::~FrameReference() {
@ -334,20 +334,20 @@ void FrameReference::Reset(blink::WebLocalFrame* frame) {
view_ = frame->view();
frame_ = frame;
} else {
view_ = NULL;
frame_ = NULL;
view_ = nullptr;
frame_ = nullptr;
}
}
blink::WebLocalFrame* FrameReference::GetFrame() {
if (view_ == NULL || frame_ == NULL)
return NULL;
for (blink::WebFrame* frame = view_->mainFrame(); frame != NULL;
if (view_ == nullptr || frame_ == nullptr)
return nullptr;
for (blink::WebFrame* frame = view_->mainFrame(); frame != nullptr;
frame = frame->traverseNext(false)) {
if (frame == frame_)
return frame_;
}
return NULL;
return nullptr;
}
blink::WebView* FrameReference::view() {
@ -477,7 +477,7 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
frame->printBegin(web_print_params_, node_to_print_);
print_params = CalculatePrintParamsForCss(frame, 0, print_params,
ignore_css_margins, fit_to_page,
NULL);
nullptr);
frame->printEnd();
}
ComputeWebKitPrintParamsInDesiredDpi(print_params, &web_print_params_);
@ -623,7 +623,7 @@ void PrepareFrameAndViewForPrint::FinishPrinting() {
web_view->close();
}
}
frame_.Reset(NULL);
frame_.Reset(nullptr);
on_ready_.Reset();
}

View file

@ -301,8 +301,8 @@ bool SpellcheckCharAttribute::OutputDefault(UChar c,
// SpellcheckWordIterator implementation:
SpellcheckWordIterator::SpellcheckWordIterator()
: text_(NULL),
attribute_(NULL),
: text_(nullptr),
attribute_(nullptr),
iterator_() {
}

View file

@ -346,7 +346,7 @@ bool URLPattern::SetPort(const std::string& port) {
bool URLPattern::MatchesURL(const GURL& test) const {
const GURL* test_url = &test;
bool has_inner_url = test.inner_url() != NULL;
bool has_inner_url = test.inner_url() != nullptr;
if (has_inner_url) {
if (!test.SchemeIsFileSystem())
@ -370,7 +370,7 @@ bool URLPattern::MatchesURL(const GURL& test) const {
bool URLPattern::MatchesSecurityOrigin(const GURL& test) const {
const GURL* test_url = &test;
bool has_inner_url = test.inner_url() != NULL;
bool has_inner_url = test.inner_url() != nullptr;
if (has_inner_url) {
if (!test.SchemeIsFileSystem())

View file

@ -123,7 +123,7 @@ int StreamListenSocket::GetPeerAddress(IPEndPoint* address) const {
}
SocketDescriptor StreamListenSocket::AcceptSocket() {
SocketDescriptor conn = HANDLE_EINTR(accept(socket_, NULL, NULL));
SocketDescriptor conn = HANDLE_EINTR(accept(socket_, nullptr, nullptr));
if (conn == kInvalidSocket)
LOG(ERROR) << "Error accepting connection.";
else