Merge pull request #6423 from electron/modernize-to-c11

Modernize to c++11
This commit is contained in:
Cheng Zhao 2016-07-11 09:03:03 +09:00 committed by GitHub
commit eae69f9728
27 changed files with 73 additions and 74 deletions

View file

@ -21,7 +21,7 @@ UvTaskRunner::~UvTaskRunner() {
bool UvTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here, bool UvTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task, const base::Closure& task,
base::TimeDelta delay) { base::TimeDelta delay) {
uv_timer_t* timer = new uv_timer_t; auto* timer = new uv_timer_t;
timer->data = this; timer->data = this;
uv_timer_init(loop_, timer); uv_timer_init(loop_, timer);
uv_timer_start(timer, UvTaskRunner::OnTimeout, delay.InMilliseconds(), 0); uv_timer_start(timer, UvTaskRunner::OnTimeout, delay.InMilliseconds(), 0);

View file

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

View file

@ -241,10 +241,10 @@ void OnGetBackend(disk_cache::Backend** backend_ptr,
} else if (action == Session::CacheAction::STATS) { } else if (action == Session::CacheAction::STATS) {
base::StringPairs stats; base::StringPairs stats;
(*backend_ptr)->GetStats(&stats); (*backend_ptr)->GetStats(&stats);
for (size_t i = 0; i < stats.size(); ++i) { for (const auto& stat : stats) {
if (stats[i].first == "Current size") { if (stat.first == "Current size") {
int current_size; int current_size;
base::StringToInt(stats[i].second, &current_size); base::StringToInt(stat.second, &current_size);
RunCallbackInUI(callback, current_size); RunCallbackInUI(callback, current_size);
break; break;
} }
@ -266,7 +266,7 @@ void DoCacheActionInIO(
// Call GetBackend and make the backend's ptr accessable in OnGetBackend. // Call GetBackend and make the backend's ptr accessable in OnGetBackend.
using BackendPtr = disk_cache::Backend*; using BackendPtr = disk_cache::Backend*;
BackendPtr* backend_ptr = new BackendPtr(nullptr); auto* backend_ptr = new BackendPtr(nullptr);
net::CompletionCallback on_get_backend = net::CompletionCallback on_get_backend =
base::Bind(&OnGetBackend, base::Owned(backend_ptr), action, callback); base::Bind(&OnGetBackend, base::Owned(backend_ptr), action, callback);
int rv = http_cache->GetBackend(backend_ptr, on_get_backend); int rv = http_cache->GetBackend(backend_ptr, on_get_backend);

View file

@ -685,10 +685,10 @@ void WebContents::TitleWasSet(content::NavigationEntry* entry,
void WebContents::DidUpdateFaviconURL( void WebContents::DidUpdateFaviconURL(
const std::vector<content::FaviconURL>& urls) { const std::vector<content::FaviconURL>& urls) {
std::set<GURL> unique_urls; std::set<GURL> unique_urls;
for (auto iter = urls.begin(); iter != urls.end(); ++iter) { for (const auto& iter : urls) {
if (iter->icon_type != content::FaviconURL::FAVICON) if (iter.icon_type != content::FaviconURL::FAVICON)
continue; continue;
const GURL& url = iter->icon_url; const GURL& url = iter.icon_url;
if (url.is_valid()) if (url.is_valid())
unique_urls.insert(url); unique_urls.insert(url);
} }

View file

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

View file

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

View file

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

View file

@ -94,7 +94,7 @@ FileSystem CreateFileSystemStruct(
} }
base::DictionaryValue* CreateFileSystemValue(const FileSystem& file_system) { base::DictionaryValue* CreateFileSystemValue(const FileSystem& file_system) {
base::DictionaryValue* file_system_value = new base::DictionaryValue(); auto* file_system_value = new base::DictionaryValue();
file_system_value->SetString("fileSystemName", file_system.file_system_name); file_system_value->SetString("fileSystemName", file_system.file_system_name);
file_system_value->SetString("rootURL", file_system.root_url); file_system_value->SetString("rootURL", file_system.root_url);
file_system_value->SetString("fileSystemPath", file_system.file_system_path); file_system_value->SetString("fileSystemPath", file_system.file_system_path);
@ -377,7 +377,7 @@ content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
void CommonWebContentsDelegate::DevToolsSaveToFile( void CommonWebContentsDelegate::DevToolsSaveToFile(
const std::string& url, const std::string& content, bool save_as) { const std::string& url, const std::string& content, bool save_as) {
base::FilePath path; base::FilePath path;
PathsMap::iterator it = saved_files_.find(url); auto it = saved_files_.find(url);
if (it != saved_files_.end() && !save_as) { if (it != saved_files_.end() && !save_as) {
path = it->second; path = it->second;
} else { } else {
@ -402,7 +402,7 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(
void CommonWebContentsDelegate::DevToolsAppendToFile( void CommonWebContentsDelegate::DevToolsAppendToFile(
const std::string& url, const std::string& content) { const std::string& url, const std::string& content) {
PathsMap::iterator it = saved_files_.find(url); auto it = saved_files_.find(url);
if (it == saved_files_.end()) if (it == saved_files_.end())
return; return;
@ -435,8 +435,8 @@ void CommonWebContentsDelegate::DevToolsRequestFileSystems() {
} }
base::ListValue file_system_value; base::ListValue file_system_value;
for (size_t i = 0; i < file_systems.size(); ++i) for (const auto& file_system : file_systems)
file_system_value.Append(CreateFileSystemValue(file_systems[i])); file_system_value.Append(CreateFileSystemValue(file_system));
web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded", web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded",
&file_system_value, nullptr, nullptr); &file_system_value, nullptr, nullptr);
} }
@ -610,9 +610,8 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
const std::string& file_system_path, const std::string& file_system_path,
const std::vector<std::string>& file_paths) { const std::vector<std::string>& file_paths) {
base::ListValue file_paths_value; base::ListValue file_paths_value;
for (std::vector<std::string>::const_iterator it(file_paths.begin()); for (const auto& file_path : file_paths) {
it != file_paths.end(); ++it) { file_paths_value.AppendString(file_path);
file_paths_value.AppendString(*it);
} }
base::FundamentalValue request_id_value(request_id); base::FundamentalValue request_id_value(request_id);
base::StringValue file_system_path_value(file_system_path); base::StringValue file_system_path_value(file_system_path);

View file

@ -22,7 +22,7 @@ net::URLRequestJob* AsarProtocolHandler::MaybeCreateJob(
net::NetworkDelegate* network_delegate) const { net::NetworkDelegate* network_delegate) const {
base::FilePath full_path; base::FilePath full_path;
net::FileURLToFilePath(request->url(), &full_path); net::FileURLToFilePath(request->url(), &full_path);
URLRequestAsarJob* job = new URLRequestAsarJob(request, network_delegate); auto* job = new URLRequestAsarJob(request, network_delegate);
job->Initialize(file_task_runner_, full_path); job->Initialize(file_task_runner_, full_path);
return job; return job;
} }

View file

@ -111,7 +111,7 @@ void URLRequestAsarJob::Start() {
if (rv != net::ERR_IO_PENDING) if (rv != net::ERR_IO_PENDING)
DidOpen(rv); DidOpen(rv);
} else if (type_ == TYPE_FILE) { } else if (type_ == TYPE_FILE) {
FileMetaInfo* meta_info = new FileMetaInfo(); auto* meta_info = new FileMetaInfo();
file_task_runner_->PostTaskAndReply( file_task_runner_->PostTaskAndReply(
FROM_HERE, FROM_HERE,
base::Bind(&URLRequestAsarJob::FetchMetaInfo, file_path_, base::Bind(&URLRequestAsarJob::FetchMetaInfo, file_path_,
@ -183,7 +183,7 @@ bool URLRequestAsarJob::IsRedirectResponse(GURL* location,
net::Filter* URLRequestAsarJob::SetupFilter() const { net::Filter* URLRequestAsarJob::SetupFilter() const {
// Bug 9936 - .svgz files needs to be decompressed. // Bug 9936 - .svgz files needs to be decompressed.
return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz") return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz")
? net::Filter::GZipFactory() : NULL; ? net::Filter::GZipFactory() : nullptr;
} }
bool URLRequestAsarJob::GetMimeType(std::string* mime_type) const { bool URLRequestAsarJob::GetMimeType(std::string* mime_type) const {
@ -224,7 +224,7 @@ int URLRequestAsarJob::GetResponseCode() const {
void URLRequestAsarJob::GetResponseInfo(net::HttpResponseInfo* info) { void URLRequestAsarJob::GetResponseInfo(net::HttpResponseInfo* info) {
std::string status("HTTP/1.1 200 OK"); std::string status("HTTP/1.1 200 OK");
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status); auto* headers = new net::HttpResponseHeaders(status);
headers->AddHeader(atom::kCORSHeader); headers->AddHeader(atom::kCORSHeader);
info->headers = headers; info->headers = headers;
@ -338,7 +338,7 @@ void URLRequestAsarJob::DidRead(scoped_refptr<net::IOBuffer> buf, int result) {
DCHECK_GE(remaining_bytes_, 0); DCHECK_GE(remaining_bytes_, 0);
} }
buf = NULL; buf = nullptr;
ReadRawDataComplete(result); ReadRawDataComplete(result);
} }

View file

@ -27,7 +27,7 @@ bool AtomURLRequestJobFactory::SetProtocolHandler(
const std::string& scheme, const std::string& scheme,
std::unique_ptr<ProtocolHandler> protocol_handler) { std::unique_ptr<ProtocolHandler> protocol_handler) {
if (!protocol_handler) { if (!protocol_handler) {
ProtocolHandlerMap::iterator it = protocol_handler_map_.find(scheme); auto it = protocol_handler_map_.find(scheme);
if (it == protocol_handler_map_.end()) if (it == protocol_handler_map_.end())
return false; return false;
@ -66,7 +66,7 @@ ProtocolHandler* AtomURLRequestJobFactory::GetProtocolHandler(
const std::string& scheme) const { const std::string& scheme) const {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme); auto it = protocol_handler_map_.find(scheme);
if (it == protocol_handler_map_.end()) if (it == protocol_handler_map_.end())
return nullptr; return nullptr;
return it->second; return it->second;
@ -87,7 +87,7 @@ net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(
net::NetworkDelegate* network_delegate) const { net::NetworkDelegate* network_delegate) const {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
ProtocolHandlerMap::const_iterator it = protocol_handler_map_.find(scheme); auto it = protocol_handler_map_.find(scheme);
if (it == protocol_handler_map_.end()) if (it == protocol_handler_map_.end())
return nullptr; return nullptr;
return it->second->MaybeCreateJob(request, network_delegate); return it->second->MaybeCreateJob(request, network_delegate);

View file

@ -40,7 +40,7 @@ void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
void URLRequestAsyncAsarJob::GetResponseInfo(net::HttpResponseInfo* info) { void URLRequestAsyncAsarJob::GetResponseInfo(net::HttpResponseInfo* info) {
std::string status("HTTP/1.1 200 OK"); std::string status("HTTP/1.1 200 OK");
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status); auto* headers = new net::HttpResponseHeaders(status);
headers->AddHeader(kCORSHeader); headers->AddHeader(kCORSHeader);
info->headers = headers; info->headers = headers;

View file

@ -72,7 +72,7 @@ void URLRequestBufferJob::GetResponseInfo(net::HttpResponseInfo* info) {
status.append(" "); status.append(" ");
status.append(net::GetHttpReasonPhrase(status_code_)); status.append(net::GetHttpReasonPhrase(status_code_));
status.append("\0\0", 2); status.append("\0\0", 2);
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status); auto* headers = new net::HttpResponseHeaders(status);
headers->AddHeader(kCORSHeader); headers->AddHeader(kCORSHeader);

View file

@ -31,7 +31,7 @@ void URLRequestStringJob::StartAsync(std::unique_ptr<base::Value> options) {
void URLRequestStringJob::GetResponseInfo(net::HttpResponseInfo* info) { void URLRequestStringJob::GetResponseInfo(net::HttpResponseInfo* info) {
std::string status("HTTP/1.1 200 OK"); std::string status("HTTP/1.1 200 OK");
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status); auto* headers = new net::HttpResponseHeaders(status);
headers->AddHeader(kCORSHeader); headers->AddHeader(kCORSHeader);

View file

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

View file

@ -30,9 +30,9 @@ bool StringToAccelerator(const std::string& shortcut,
// Now, parse it into an accelerator. // Now, parse it into an accelerator.
int modifiers = ui::EF_NONE; int modifiers = ui::EF_NONE;
ui::KeyboardCode key = ui::VKEY_UNKNOWN; ui::KeyboardCode key = ui::VKEY_UNKNOWN;
for (size_t i = 0; i < tokens.size(); i++) { for (const auto& token : tokens) {
bool shifted = false; bool shifted = false;
ui::KeyboardCode code = atom::KeyboardCodeFromStr(tokens[i], &shifted); ui::KeyboardCode code = atom::KeyboardCodeFromStr(token, &shifted);
if (shifted) if (shifted)
modifiers |= ui::EF_SHIFT_DOWN; modifiers |= ui::EF_SHIFT_DOWN;
switch (code) { switch (code) {

View file

@ -17,7 +17,7 @@ base::LazyInstance<base::ObserverList<WindowListObserver>>::Leaky
WindowList::observers_ = LAZY_INSTANCE_INITIALIZER; WindowList::observers_ = LAZY_INSTANCE_INITIALIZER;
// static // static
WindowList* WindowList::instance_ = NULL; WindowList* WindowList::instance_ = nullptr;
// static // static
WindowList* WindowList::GetInstance() { WindowList* WindowList::GetInstance() {
@ -70,8 +70,8 @@ void WindowList::RemoveObserver(WindowListObserver* observer) {
// static // static
void WindowList::CloseAllWindows() { void WindowList::CloseAllWindows() {
WindowVector windows = GetInstance()->windows_; WindowVector windows = GetInstance()->windows_;
for (size_t i = 0; i < windows.size(); ++i) for (const auto& window : windows)
windows[i]->Close(); window->Close();
} }
WindowList::WindowList() { WindowList::WindowList() {

View file

@ -63,10 +63,10 @@ float GetScaleFactorFromPath(const base::FilePath& path) {
// We don't try to convert string to float here because it is very very // We don't try to convert string to float here because it is very very
// expensive. // expensive.
for (unsigned i = 0; i < node::arraysize(kScaleFactorPairs); ++i) { for (const auto& kScaleFactorPair : kScaleFactorPairs) {
if (base::EndsWith(filename, kScaleFactorPairs[i].name, if (base::EndsWith(filename, kScaleFactorPair.name,
base::CompareCase::INSENSITIVE_ASCII)) base::CompareCase::INSENSITIVE_ASCII))
return kScaleFactorPairs[i].scale; return kScaleFactorPair.scale;
} }
return 1.0f; return 1.0f;

View file

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

View file

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

View file

@ -123,7 +123,7 @@ v8::Local<v8::Value> CreateFunctionFromTranslater(
v8::Local<v8::FunctionTemplate> call_translater = v8::Local<v8::FunctionTemplate> call_translater =
v8::Local<v8::FunctionTemplate>::New(isolate, g_call_translater); v8::Local<v8::FunctionTemplate>::New(isolate, g_call_translater);
TranslaterHolder* holder = new TranslaterHolder; auto* holder = new TranslaterHolder;
holder->translater = translater; holder->translater = translater;
return BindFunctionWith(isolate, return BindFunctionWith(isolate,
isolate->GetCurrentContext(), isolate->GetCurrentContext(),

View file

@ -55,7 +55,7 @@ class V8ValueConverter::FromV8ValueState {
// hash. Different hash obviously means different objects, but two objects // hash. Different hash obviously means different objects, but two objects
// in a couple of thousands could have the same identity hash. // in a couple of thousands could have the same identity hash.
std::pair<Iterator, Iterator> range = unique_map_.equal_range(hash); std::pair<Iterator, Iterator> range = unique_map_.equal_range(hash);
for (Iterator it = range.first; it != range.second; ++it) { for (auto it = range.first; it != range.second; ++it) {
// Operator == for handles actually compares the underlying objects. // Operator == for handles actually compares the underlying objects.
if (it->second == handle) if (it->second == handle)
return false; return false;
@ -162,7 +162,7 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Array(
v8::Local<v8::Array> result(v8::Array::New(isolate, val->GetSize())); v8::Local<v8::Array> result(v8::Array::New(isolate, val->GetSize()));
for (size_t i = 0; i < val->GetSize(); ++i) { for (size_t i = 0; i < val->GetSize(); ++i) {
const base::Value* child = NULL; const base::Value* child = nullptr;
CHECK(val->Get(i, &child)); CHECK(val->Get(i, &child));
v8::Local<v8::Value> child_v8 = ToV8ValueImpl(isolate, child); v8::Local<v8::Value> child_v8 = ToV8ValueImpl(isolate, child);
@ -214,7 +214,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
FromV8ValueState::Level state_level(state); FromV8ValueState::Level state_level(state);
if (state->HasReachedMaxRecursionDepth()) if (state->HasReachedMaxRecursionDepth())
return NULL; return nullptr;
if (val->IsNull()) if (val->IsNull())
return base::Value::CreateNullValue().release(); return base::Value::CreateNullValue().release();
@ -235,7 +235,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
if (val->IsUndefined()) if (val->IsUndefined())
// JSON.stringify ignores undefined. // JSON.stringify ignores undefined.
return NULL; return nullptr;
if (val->IsDate()) { if (val->IsDate()) {
v8::Date* date = v8::Date::Cast(*val); v8::Date* date = v8::Date::Cast(*val);
@ -265,7 +265,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
if (val->IsFunction()) { if (val->IsFunction()) {
if (!function_allowed_) if (!function_allowed_)
// JSON.stringify refuses to convert function(){}. // JSON.stringify refuses to convert function(){}.
return NULL; return nullptr;
return FromV8Object(val->ToObject(), state, isolate); return FromV8Object(val->ToObject(), state, isolate);
} }
@ -278,7 +278,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
} }
LOG(ERROR) << "Unexpected v8 value type encountered."; LOG(ERROR) << "Unexpected v8 value type encountered.";
return NULL; return nullptr;
} }
base::Value* V8ValueConverter::FromV8Array( base::Value* V8ValueConverter::FromV8Array(
@ -295,7 +295,7 @@ base::Value* V8ValueConverter::FromV8Array(
val->CreationContext() != isolate->GetCurrentContext()) val->CreationContext() != isolate->GetCurrentContext())
scope.reset(new v8::Context::Scope(val->CreationContext())); scope.reset(new v8::Context::Scope(val->CreationContext()));
base::ListValue* result = new base::ListValue(); auto* result = new base::ListValue();
// Only fields with integer keys are carried over to the ListValue. // Only fields with integer keys are carried over to the ListValue.
for (uint32_t i = 0; i < val->Length(); ++i) { for (uint32_t i = 0; i < val->Length(); ++i) {

View file

@ -54,7 +54,8 @@ void NodeBindingsMac::PollEvents() {
// Wait for new libuv events. // Wait for new libuv events.
int r; int r;
do { 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); } while (r == -1 && errno == EINTR);
} }

View file

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

View file

@ -39,7 +39,7 @@ class ScriptExecutionCallback : public blink::WebScriptExecutionCallback {
explicit ScriptExecutionCallback(const CompletionCallback& callback) explicit ScriptExecutionCallback(const CompletionCallback& callback)
: callback_(callback) {} : callback_(callback) {}
~ScriptExecutionCallback() {} ~ScriptExecutionCallback() override {}
void completed( void completed(
const blink::WebVector<v8::Local<v8::Value>>& result) override { const blink::WebVector<v8::Local<v8::Value>>& result) override {

View file

@ -132,10 +132,10 @@ void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) {
blink::WebVector<blink::WebDraggableRegion> webregions = blink::WebVector<blink::WebDraggableRegion> webregions =
frame->document().draggableRegions(); frame->document().draggableRegions();
std::vector<DraggableRegion> regions; std::vector<DraggableRegion> regions;
for (size_t i = 0; i < webregions.size(); ++i) { for (const auto& webregion : webregions) {
DraggableRegion region; DraggableRegion region;
region.bounds = webregions[i].bounds; region.bounds = webregion.bounds;
region.draggable = webregions[i].draggable; region.draggable = webregion.draggable;
regions.push_back(region); regions.push_back(region);
} }
Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions)); Send(new AtomViewHostMsg_UpdateDraggableRegions(routing_id(), regions));

View file

@ -58,8 +58,7 @@ bool AtomContentUtilityClient::OnMessageReceived(
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
for (Handlers::iterator it = handlers_.begin(); for (auto it = handlers_.begin(); !handled && it != handlers_.end(); ++it) {
!handled && it != handlers_.end(); ++it) {
handled = (*it)->OnMessageReceived(message); handled = (*it)->OnMessageReceived(message);
} }