chore: run clang-format to clear linter for #14977 (#14990)

This commit is contained in:
Charles Kerr 2018-10-05 10:38:27 -05:00 committed by GitHub
parent 8abe43ac8b
commit 859567983a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 29 deletions

View file

@ -34,7 +34,8 @@ StreamSubscriber::~StreamSubscriber() {
RemoveAllListeners(); RemoveAllListeners();
} }
void StreamSubscriber::On(const std::string& event, EventCallback&& callback) { // NOLINT void StreamSubscriber::On(const std::string& event,
EventCallback&& callback) { // NOLINT
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(js_handlers_.find(event) == js_handlers_.end()); DCHECK(js_handlers_.find(event) == js_handlers_.end());
@ -44,7 +45,7 @@ void StreamSubscriber::On(const std::string& event, EventCallback&& callback) {
// emitter.on(event, EventEmitted) // emitter.on(event, EventEmitted)
auto fn = CallbackToV8(isolate_, callback); auto fn = CallbackToV8(isolate_, callback);
js_handlers_[event] = v8::Global<v8::Value>(isolate_, fn); js_handlers_[event] = v8::Global<v8::Value>(isolate_, fn);
internal::ValueVector args = { StringToV8(isolate_, event), fn }; internal::ValueVector args = {StringToV8(isolate_, event), fn};
internal::CallMethodWithArgs(isolate_, emitter_.Get(isolate_), "on", &args); internal::CallMethodWithArgs(isolate_, emitter_.Get(isolate_), "on", &args);
} }
@ -77,8 +78,8 @@ void StreamSubscriber::OnData(mate::Arguments* args) {
std::vector<char> buffer(data, data + length); std::vector<char> buffer(data, data + length);
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE, content::BrowserThread::IO, FROM_HERE,
base::Bind(&atom::URLRequestStreamJob::OnData, base::Bind(&atom::URLRequestStreamJob::OnData, url_job_,
url_job_, base::Passed(&buffer))); base::Passed(&buffer)));
} }
void StreamSubscriber::OnEnd(mate::Arguments* args) { void StreamSubscriber::OnEnd(mate::Arguments* args) {
@ -103,8 +104,8 @@ void StreamSubscriber::RemoveAllListeners() {
} }
void StreamSubscriber::RemoveListener(JSHandlersMap::iterator it) { void StreamSubscriber::RemoveListener(JSHandlersMap::iterator it) {
internal::ValueVector args = { StringToV8(isolate_, it->first), internal::ValueVector args = {StringToV8(isolate_, it->first),
it->second.Get(isolate_) }; it->second.Get(isolate_)};
internal::CallMethodWithArgs(isolate_, emitter_.Get(isolate_), internal::CallMethodWithArgs(isolate_, emitter_.Get(isolate_),
"removeListener", &args); "removeListener", &args);
js_handlers_.erase(it); js_handlers_.erase(it);

View file

@ -26,8 +26,8 @@ class Arguments;
class StreamSubscriber { class StreamSubscriber {
public: public:
StreamSubscriber(v8::Isolate* isolate, StreamSubscriber(v8::Isolate* isolate,
v8::Local<v8::Object> emitter, v8::Local<v8::Object> emitter,
base::WeakPtr<atom::URLRequestStreamJob> url_job); base::WeakPtr<atom::URLRequestStreamJob> url_job);
~StreamSubscriber(); ~StreamSubscriber();
private: private:

View file

@ -12,7 +12,7 @@
namespace base { namespace base {
class ListValue; class ListValue;
class DictionaryValue; class DictionaryValue;
} } // namespace base
namespace atom { namespace atom {

View file

@ -87,7 +87,7 @@ void URLRequestStreamJob::BeforeStartInUI(v8::Isolate* isolate,
} }
subscriber_.reset(new mate::StreamSubscriber(isolate, data.GetHandle(), subscriber_.reset(new mate::StreamSubscriber(isolate, data.GetHandle(),
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
} }
void URLRequestStreamJob::StartAsync(std::unique_ptr<base::Value> options) { void URLRequestStreamJob::StartAsync(std::unique_ptr<base::Value> options) {
@ -123,8 +123,8 @@ void URLRequestStreamJob::OnEnd() {
} }
void URLRequestStreamJob::OnError() { void URLRequestStreamJob::OnError() {
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, NotifyStartError(
net::ERR_FAILED)); net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED));
} }
int URLRequestStreamJob::ReadRawData(net::IOBuffer* dest, int dest_size) { int URLRequestStreamJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
@ -186,7 +186,8 @@ void URLRequestStreamJob::GetResponseInfo(net::HttpResponseInfo* info) {
} }
int URLRequestStreamJob::BufferCopy(std::vector<char>* source, int URLRequestStreamJob::BufferCopy(std::vector<char>* source,
net::IOBuffer* target, int target_size) { net::IOBuffer* target,
int target_size) {
int bytes_written = std::min(static_cast<int>(source->size()), target_size); int bytes_written = std::min(static_cast<int>(source->size()), target_size);
memcpy(target->data(), source->data(), bytes_written); memcpy(target->data(), source->data(), bytes_written);
return bytes_written; return bytes_written;

View file

@ -49,7 +49,8 @@ class URLRequestStreamJob : public JsAsker<net::URLRequestJob> {
void OnResponse(bool success, std::unique_ptr<base::Value> value); void OnResponse(bool success, std::unique_ptr<base::Value> value);
int BufferCopy(std::vector<char>* source, int BufferCopy(std::vector<char>* source,
net::IOBuffer* target, int target_size); net::IOBuffer* target,
int target_size);
// Saved arguments passed to ReadRawData. // Saved arguments passed to ReadRawData.
scoped_refptr<net::IOBuffer> pending_buf_; scoped_refptr<net::IOBuffer> pending_buf_;

View file

@ -27,8 +27,8 @@
#include "content/public/browser/context_factory.h" #include "content/public/browser/context_factory.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/blink/public/platform/web_input_event.h" #include "third_party/blink/public/platform/web_input_event.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/compositor/compositor.h" #include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_type.h" #include "ui/compositor/layer_type.h"

View file

@ -92,7 +92,7 @@ bool TriggerAcceleratorTableCommand(AcceleratorTable* table,
const accelerator_util::MenuItem& item = (*table)[accelerator]; const accelerator_util::MenuItem& item = (*table)[accelerator];
if (item.model->IsEnabledAt(item.position)) { if (item.model->IsEnabledAt(item.position)) {
const auto event_flags = const auto event_flags =
accelerator.MaskOutKeyEventFlags(accelerator.modifiers()); accelerator.MaskOutKeyEventFlags(accelerator.modifiers());
item.model->ActivatedAt(item.position, event_flags); item.model->ActivatedAt(item.position, event_flags);
return true; return true;
} }

View file

@ -114,8 +114,9 @@ v8::Local<v8::Function> SafeV8Function::NewHandle(v8::Isolate* isolate) const {
return v8_function_->NewHandle(isolate); return v8_function_->NewHandle(isolate);
} }
v8::Local<v8::Value> CreateFunctionFromTranslater( v8::Local<v8::Value> CreateFunctionFromTranslater(v8::Isolate* isolate,
v8::Isolate* isolate, const Translater& translater, bool one_time) { const Translater& translater,
bool one_time) {
// The FunctionTemplate is cached. // The FunctionTemplate is cached.
if (g_call_translater.IsEmpty()) if (g_call_translater.IsEmpty())
g_call_translater.Reset(isolate, mate::CreateFunctionTemplate( g_call_translater.Reset(isolate, mate::CreateFunctionTemplate(
@ -128,11 +129,9 @@ v8::Local<v8::Value> CreateFunctionFromTranslater(
Dictionary state = mate::Dictionary::CreateEmpty(isolate); Dictionary state = mate::Dictionary::CreateEmpty(isolate);
if (one_time) if (one_time)
state.Set("oneTime", true); state.Set("oneTime", true);
return BindFunctionWith(isolate, return BindFunctionWith(isolate, isolate->GetCurrentContext(),
isolate->GetCurrentContext(),
call_translater->GetFunction(), call_translater->GetFunction(),
holder->handle.Get(isolate), holder->handle.Get(isolate), state.GetHandle());
state.GetHandle());
} }
// func.bind(func, arg1). // func.bind(func, arg1).

View file

@ -108,8 +108,9 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
// Helper to pass a C++ funtion to JavaScript. // Helper to pass a C++ funtion to JavaScript.
using Translater = base::Callback<void(Arguments* args)>; using Translater = base::Callback<void(Arguments* args)>;
v8::Local<v8::Value> CreateFunctionFromTranslater( v8::Local<v8::Value> CreateFunctionFromTranslater(v8::Isolate* isolate,
v8::Isolate* isolate, const Translater& translater, bool one_time); const Translater& translater,
bool one_time);
v8::Local<v8::Value> BindFunctionWith(v8::Isolate* isolate, v8::Local<v8::Value> BindFunctionWith(v8::Isolate* isolate,
v8::Local<v8::Context> context, v8::Local<v8::Context> context,
v8::Local<v8::Function> func, v8::Local<v8::Function> func,
@ -152,8 +153,8 @@ struct Converter<base::RepeatingCallback<Sig>> {
const base::RepeatingCallback<Sig>& val) { const base::RepeatingCallback<Sig>& val) {
// We don't use CreateFunctionTemplate here because it creates a new // We don't use CreateFunctionTemplate here because it creates a new
// FunctionTemplate everytime, which is cached by V8 and causes leaks. // FunctionTemplate everytime, which is cached by V8 and causes leaks.
internal::Translater translater = base::Bind( internal::Translater translater =
&internal::NativeFunctionInvoker<Sig>::Go, val); base::Bind(&internal::NativeFunctionInvoker<Sig>::Go, val);
// To avoid memory leak, we ensure that the callback can only be called // To avoid memory leak, we ensure that the callback can only be called
// for once. // for once.
return internal::CreateFunctionFromTranslater(isolate, translater, true); return internal::CreateFunctionFromTranslater(isolate, translater, true);
@ -172,11 +173,11 @@ struct Converter<base::RepeatingCallback<Sig>> {
// Convert a callback to V8 without the call number limitation, this can easily // Convert a callback to V8 without the call number limitation, this can easily
// cause memory leaks so use it with caution. // cause memory leaks so use it with caution.
template<typename Sig> template <typename Sig>
v8::Local<v8::Value> CallbackToV8(v8::Isolate* isolate, v8::Local<v8::Value> CallbackToV8(v8::Isolate* isolate,
const base::Callback<Sig>& val) { const base::Callback<Sig>& val) {
internal::Translater translater = base::Bind( internal::Translater translater =
&internal::NativeFunctionInvoker<Sig>::Go, val); base::Bind(&internal::NativeFunctionInvoker<Sig>::Go, val);
return internal::CreateFunctionFromTranslater(isolate, translater, false); return internal::CreateFunctionFromTranslater(isolate, translater, false);
} }