chore: convert some more files from base::Bind (#17968)

This commit is contained in:
Shelley Vohr 2019-04-27 18:03:06 -07:00 committed by Cheng Zhao
parent 72baff1c88
commit fe618631f1
5 changed files with 20 additions and 16 deletions

View file

@ -392,8 +392,8 @@ void BrowserWindow::ScheduleUnresponsiveEvent(int ms) {
if (!window_unresponsive_closure_.IsCancelled()) if (!window_unresponsive_closure_.IsCancelled())
return; return;
window_unresponsive_closure_.Reset( window_unresponsive_closure_.Reset(base::BindRepeating(
base::Bind(&BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr())); &BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr()));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, window_unresponsive_closure_.callback(), FROM_HERE, window_unresponsive_closure_.callback(),
base::TimeDelta::FromMilliseconds(ms)); base::TimeDelta::FromMilliseconds(ms));
@ -474,8 +474,9 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) { void* priv) {
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("BrowserWindow", mate::CreateConstructor<BrowserWindow>( dict.Set("BrowserWindow",
isolate, base::Bind(&BrowserWindow::New))); mate::CreateConstructor<BrowserWindow>(
isolate, base::BindRepeating(&BrowserWindow::New)));
} }
} // namespace } // namespace

View file

@ -53,7 +53,7 @@ struct Converter<base::trace_event::TraceConfig> {
namespace { namespace {
using CompletionCallback = base::Callback<void(const base::FilePath&)>; using CompletionCallback = base::RepeatingCallback<void(const base::FilePath&)>;
scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint( scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
const base::FilePath& path, const base::FilePath& path,
@ -68,7 +68,7 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
LOG(ERROR) << "Creating temporary file failed"; LOG(ERROR) << "Creating temporary file failed";
return TracingController::CreateFileEndpoint( return TracingController::CreateFileEndpoint(
result_file_path, base::Bind(callback, result_file_path)); result_file_path, base::BindRepeating(callback, result_file_path));
} }
v8::Local<v8::Promise> StopRecording(v8::Isolate* isolate, v8::Local<v8::Promise> StopRecording(v8::Isolate* isolate,
@ -79,9 +79,10 @@ v8::Local<v8::Promise> StopRecording(v8::Isolate* isolate,
// TODO(zcbenz): Remove the use of CopyablePromise when the // TODO(zcbenz): Remove the use of CopyablePromise when the
// CreateFileEndpoint API accepts OnceCallback. // CreateFileEndpoint API accepts OnceCallback.
TracingController::GetInstance()->StopTracing(GetTraceDataEndpoint( TracingController::GetInstance()->StopTracing(GetTraceDataEndpoint(
path, base::Bind(atom::util::CopyablePromise::ResolveCopyablePromise< path,
const base::FilePath&>, base::BindRepeating(atom::util::CopyablePromise::ResolveCopyablePromise<
atom::util::CopyablePromise(promise)))); const base::FilePath&>,
atom::util::CopyablePromise(promise))));
return handle; return handle;
} }

View file

@ -176,7 +176,8 @@ Cookies::Cookies(v8::Isolate* isolate, AtomBrowserContext* browser_context)
Init(isolate); Init(isolate);
cookie_change_subscription_ = cookie_change_subscription_ =
browser_context_->cookie_change_notifier()->RegisterCookieChangeCallback( browser_context_->cookie_change_notifier()->RegisterCookieChangeCallback(
base::Bind(&Cookies::OnCookieChanged, base::Unretained(this))); base::BindRepeating(&Cookies::OnCookieChanged,
base::Unretained(this)));
} }
Cookies::~Cookies() {} Cookies::~Cookies() {}

View file

@ -41,10 +41,11 @@ void MenuMac::PopupAt(TopLevelWindow* window,
if (!native_window) if (!native_window)
return; return;
auto popup = base::Bind(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(), auto popup =
native_window->GetWeakPtr(), window->weak_map_id(), x, base::BindOnce(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
y, positioning_item, callback); native_window->GetWeakPtr(), window->weak_map_id(), x, y,
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, popup); positioning_item, callback);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, std::move(popup));
} }
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window, void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
@ -57,7 +58,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
return; return;
NSWindow* nswindow = native_window->GetNativeWindow().GetNativeNSWindow(); NSWindow* nswindow = native_window->GetNativeWindow().GetNativeNSWindow();
auto close_callback = base::Bind( auto close_callback = base::BindRepeating(
&MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback); &MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
popup_controllers_[window_id] = base::scoped_nsobject<AtomMenuController>([ popup_controllers_[window_id] = base::scoped_nsobject<AtomMenuController>([
[AtomMenuController alloc] initWithModel:model() [AtomMenuController alloc] initWithModel:model()

View file

@ -46,7 +46,7 @@ void MenuViews::PopupAt(TopLevelWindow* window,
// Show the menu. // Show the menu.
int32_t window_id = window->weak_map_id(); int32_t window_id = window->weak_map_id();
auto close_callback = base::Bind( auto close_callback = base::BindRepeating(
&MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback); &MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
menu_runners_[window_id] = menu_runners_[window_id] =
std::make_unique<MenuRunner>(model(), flags, close_callback); std::make_unique<MenuRunner>(model(), flags, close_callback);