chore: remove last instances of base::Bind (#18178)

* chore: remove last instances of base::Bind

* MessageBoxCallback is a OnceCallback

* convert permission helepr cbs to Once

* convert ResponseCallback to Once
This commit is contained in:
Shelley Vohr 2019-05-29 13:02:15 -07:00 committed by GitHub
parent 96371b6d75
commit 9af5072115
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 122 additions and 109 deletions

View file

@ -100,16 +100,17 @@ class Menu : public mate::TrackableObject<Menu>,
bool WorksWhenHiddenAt(int index) const; bool WorksWhenHiddenAt(int index) const;
// Stored delegate methods. // Stored delegate methods.
base::Callback<bool(v8::Local<v8::Value>, int)> is_checked_; base::RepeatingCallback<bool(v8::Local<v8::Value>, int)> is_checked_;
base::Callback<bool(v8::Local<v8::Value>, int)> is_enabled_; base::RepeatingCallback<bool(v8::Local<v8::Value>, int)> is_enabled_;
base::Callback<bool(v8::Local<v8::Value>, int)> is_visible_; base::RepeatingCallback<bool(v8::Local<v8::Value>, int)> is_visible_;
base::Callback<bool(v8::Local<v8::Value>, int)> works_when_hidden_; base::RepeatingCallback<bool(v8::Local<v8::Value>, int)> works_when_hidden_;
base::Callback<v8::Local<v8::Value>(v8::Local<v8::Value>, int, bool)> base::RepeatingCallback<v8::Local<v8::Value>(v8::Local<v8::Value>, int, bool)>
get_accelerator_; get_accelerator_;
base::Callback<bool(v8::Local<v8::Value>, int)> should_register_accelerator_; base::RepeatingCallback<bool(v8::Local<v8::Value>, int)>
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>, int)> should_register_accelerator_;
base::RepeatingCallback<void(v8::Local<v8::Value>, v8::Local<v8::Value>, int)>
execute_command_; execute_command_;
base::Callback<void(v8::Local<v8::Value>)> menu_will_show_; base::RepeatingCallback<void(v8::Local<v8::Value>)> menu_will_show_;
DISALLOW_COPY_AND_ASSIGN(Menu); DISALLOW_COPY_AND_ASSIGN(Menu);
}; };

View file

@ -40,9 +40,10 @@ void RegisterSchemesAsPrivileged(v8::Local<v8::Value> val,
class Protocol : public mate::TrackableObject<Protocol> { class Protocol : public mate::TrackableObject<Protocol> {
public: public:
using Handler = using Handler = base::RepeatingCallback<void(const base::DictionaryValue&,
base::Callback<void(const base::DictionaryValue&, v8::Local<v8::Value>)>; v8::Local<v8::Value>)>;
using CompletionCallback = base::Callback<void(v8::Local<v8::Value>)>; using CompletionCallback =
base::RepeatingCallback<void(v8::Local<v8::Value>)>;
static mate::Handle<Protocol> Create(v8::Isolate* isolate, static mate::Handle<Protocol> Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context); AtomBrowserContext* browser_context);

View file

@ -48,7 +48,8 @@ class ProtocolNS : public mate::TrackableObject<ProtocolNS> {
~ProtocolNS() override; ~ProtocolNS() override;
// Callback types. // Callback types.
using CompletionCallback = base::Callback<void(v8::Local<v8::Value>)>; using CompletionCallback =
base::RepeatingCallback<void(v8::Local<v8::Value>)>;
// JS APIs. // JS APIs.
ProtocolError RegisterProtocol(ProtocolType type, ProtocolError RegisterProtocol(ProtocolType type,

View file

@ -66,7 +66,8 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
using NotificationCallback = using NotificationCallback =
base::Callback<void(const std::string&, const base::DictionaryValue&)>; base::RepeatingCallback<void(const std::string&,
const base::DictionaryValue&)>;
void PostNotification(const std::string& name, void PostNotification(const std::string& name,
const base::DictionaryValue& user_info, const base::DictionaryValue& user_info,

View file

@ -211,7 +211,8 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
void SetIcon(mate::Handle<NativeImage> icon); void SetIcon(mate::Handle<NativeImage> icon);
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
typedef base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)> typedef base::RepeatingCallback<void(v8::Local<v8::Value>,
v8::Local<v8::Value>)>
MessageCallback; MessageCallback;
bool HookWindowMessage(UINT message, const MessageCallback& callback); bool HookWindowMessage(UINT message, const MessageCallback& callback);
bool IsWindowMessageHooked(UINT message); bool IsWindowMessageHooked(UINT message);

View file

@ -9,8 +9,8 @@
#include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_context.h"
#include "atom/browser/net/atom_network_delegate.h" #include "atom/browser/net/atom_network_delegate.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/net_converter.h" #include "atom/common/native_mate_converters/net_converter.h"
#include "atom/common/native_mate_converters/once_callback.h"
#include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/native_mate_converters/value_converter.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"

View file

@ -28,7 +28,7 @@ class FrameSubscriber : public content::WebContentsObserver,
public viz::mojom::FrameSinkVideoConsumer { public viz::mojom::FrameSinkVideoConsumer {
public: public:
using FrameCaptureCallback = using FrameCaptureCallback =
base::Callback<void(const gfx::Image&, const gfx::Rect&)>; base::RepeatingCallback<void(const gfx::Image&, const gfx::Rect&)>;
FrameSubscriber(content::WebContents* web_contents, FrameSubscriber(content::WebContents* web_contents,
const FrameCaptureCallback& callback, const FrameCaptureCallback& callback,

View file

@ -561,7 +561,7 @@ void AtomBrowserClient::AllowCertificateError(
bool is_main_frame_request, bool is_main_frame_request,
bool strict_enforcement, bool strict_enforcement,
bool expired_previous_decision, bool expired_previous_decision,
const base::Callback<void(content::CertificateRequestResultType)>& const base::RepeatingCallback<void(content::CertificateRequestResultType)>&
callback) { callback) {
if (delegate_) { if (delegate_) {
delegate_->AllowCertificateError( delegate_->AllowCertificateError(
@ -743,21 +743,21 @@ content::BrowserMainParts* AtomBrowserClient::CreateBrowserMainParts(
void AtomBrowserClient::WebNotificationAllowed( void AtomBrowserClient::WebNotificationAllowed(
int render_process_id, int render_process_id,
const base::RepeatingCallback<void(bool, bool)>& callback) { base::OnceCallback<void(bool, bool)> callback) {
content::WebContents* web_contents = content::WebContents* web_contents =
WebContentsPreferences::GetWebContentsFromProcessID(render_process_id); WebContentsPreferences::GetWebContentsFromProcessID(render_process_id);
if (!web_contents) { if (!web_contents) {
callback.Run(false, false); std::move(callback).Run(false, false);
return; return;
} }
auto* permission_helper = auto* permission_helper =
WebContentsPermissionHelper::FromWebContents(web_contents); WebContentsPermissionHelper::FromWebContents(web_contents);
if (!permission_helper) { if (!permission_helper) {
callback.Run(false, false); std::move(callback).Run(false, false);
return; return;
} }
permission_helper->RequestWebNotificationPermission( permission_helper->RequestWebNotificationPermission(
base::Bind(callback, web_contents->IsAudioMuted())); base::BindOnce(std::move(callback), web_contents->IsAudioMuted()));
} }
void AtomBrowserClient::RenderProcessHostDestroyed( void AtomBrowserClient::RenderProcessHostDestroyed(
@ -809,9 +809,9 @@ void HandleExternalProtocolInUI(
return; return;
GURL escaped_url(net::EscapeExternalHandlerValue(url.spec())); GURL escaped_url(net::EscapeExternalHandlerValue(url.spec()));
auto callback = base::Bind(&OnOpenExternal, escaped_url); auto callback = base::BindOnce(&OnOpenExternal, escaped_url);
permission_helper->RequestOpenExternalPermission(callback, has_user_gesture, permission_helper->RequestOpenExternalPermission(std::move(callback),
url); has_user_gesture, url);
} }
bool AtomBrowserClient::HandleExternalProtocol( bool AtomBrowserClient::HandleExternalProtocol(

View file

@ -52,7 +52,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
NotificationPresenter* GetNotificationPresenter(); NotificationPresenter* GetNotificationPresenter();
void WebNotificationAllowed(int render_process_id, void WebNotificationAllowed(int render_process_id,
const base::Callback<void(bool, bool)>& callback); base::OnceCallback<void(bool, bool)> callback);
// content::NavigatorDelegate // content::NavigatorDelegate
std::vector<std::unique_ptr<content::NavigationThrottle>> std::vector<std::unique_ptr<content::NavigationThrottle>>

View file

@ -95,9 +95,9 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
window, atom::MessageBoxType::kNone, buttons, default_id, cancel_id, window, atom::MessageBoxType::kNone, buttons, default_id, cancel_id,
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "", atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(), base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback, base::BindOnce(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
base::Unretained(this), base::Passed(std::move(callback)), base::Unretained(this), base::Passed(std::move(callback)),
origin)); origin));
} }
void AtomJavaScriptDialogManager::RunBeforeUnloadDialog( void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(

View file

@ -523,15 +523,15 @@ void CommonWebContentsDelegate::DevToolsIndexPath(
scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>( scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>(
devtools_file_system_indexer_->IndexPath( devtools_file_system_indexer_->IndexPath(
file_system_path, excluded_folders, file_system_path, excluded_folders,
base::Bind( base::BindRepeating(
&CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated, &CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated,
weak_factory_.GetWeakPtr(), request_id, file_system_path), weak_factory_.GetWeakPtr(), request_id, file_system_path),
base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingWorked, base::BindRepeating(
weak_factory_.GetWeakPtr(), request_id, &CommonWebContentsDelegate::OnDevToolsIndexingWorked,
file_system_path), weak_factory_.GetWeakPtr(), request_id, file_system_path),
base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingDone, base::BindRepeating(
weak_factory_.GetWeakPtr(), request_id, &CommonWebContentsDelegate::OnDevToolsIndexingDone,
file_system_path))); weak_factory_.GetWeakPtr(), request_id, file_system_path)));
} }
void CommonWebContentsDelegate::DevToolsStopIndexing(int request_id) { void CommonWebContentsDelegate::DevToolsStopIndexing(int request_id) {
@ -553,8 +553,9 @@ void CommonWebContentsDelegate::DevToolsSearchInPath(
} }
devtools_file_system_indexer_->SearchInPath( devtools_file_system_indexer_->SearchInPath(
file_system_path, query, file_system_path, query,
base::Bind(&CommonWebContentsDelegate::OnDevToolsSearchCompleted, base::BindRepeating(&CommonWebContentsDelegate::OnDevToolsSearchCompleted,
weak_factory_.GetWeakPtr(), request_id, file_system_path)); weak_factory_.GetWeakPtr(), request_id,
file_system_path));
} }
void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated( void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(

View file

@ -70,17 +70,16 @@ void RunSimpleListener(const AtomNetworkDelegate::SimpleListener& listener,
return listener.Run(*(details.get())); return listener.Run(*(details.get()));
} }
void RunResponseListener( void RunResponseListener(const AtomNetworkDelegate::ResponseListener& listener,
const AtomNetworkDelegate::ResponseListener& listener, std::unique_ptr<base::DictionaryValue> details,
std::unique_ptr<base::DictionaryValue> details, int render_process_id,
int render_process_id, int render_frame_id,
int render_frame_id, AtomNetworkDelegate::ResponseCallback callback) {
const AtomNetworkDelegate::ResponseCallback& callback) {
int32_t id = GetWebContentsID(render_process_id, render_frame_id); int32_t id = GetWebContentsID(render_process_id, render_frame_id);
// id must be greater than zero // id must be greater than zero
if (id) if (id)
details->SetInteger("webContentsId", id); details->SetInteger("webContentsId", id);
return listener.Run(*(details.get()), callback); return listener.Run(*(details.get()), std::move(callback));
} }
// Test whether the URL of |request| matches |patterns|. // Test whether the URL of |request| matches |patterns|.
@ -484,12 +483,12 @@ int AtomNetworkDelegate::HandleResponseEvent(
callbacks_[request->identifier()] = std::move(callback); callbacks_[request->identifier()] = std::move(callback);
ResponseCallback response = ResponseCallback response =
base::Bind(&AtomNetworkDelegate::OnListenerResultInUI<Out>, base::BindOnce(&AtomNetworkDelegate::OnListenerResultInUI<Out>,
base::Unretained(this), request->identifier(), out); base::Unretained(this), request->identifier(), out);
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce(RunResponseListener, info.listener, std::move(details), base::BindOnce(RunResponseListener, info.listener, std::move(details),
render_process_id, render_frame_id, response)); render_process_id, render_frame_id, std::move(response)));
return net::ERR_IO_PENDING; return net::ERR_IO_PENDING;
} }

View file

@ -32,10 +32,13 @@ class LoginHandler;
class AtomNetworkDelegate : public net::NetworkDelegate { class AtomNetworkDelegate : public net::NetworkDelegate {
public: public:
using ResponseCallback = base::Callback<void(const base::DictionaryValue&)>; using ResponseCallback =
using SimpleListener = base::Callback<void(const base::DictionaryValue&)>; base::OnceCallback<void(const base::DictionaryValue&)>;
using ResponseListener = base::Callback<void(const base::DictionaryValue&, using SimpleListener =
const ResponseCallback&)>; base::RepeatingCallback<void(const base::DictionaryValue&)>;
using ResponseListener =
base::RepeatingCallback<void(const base::DictionaryValue&,
ResponseCallback)>;
enum SimpleEvent { enum SimpleEvent {
kOnSendHeaders, kOnSendHeaders,

View file

@ -265,8 +265,8 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
if (content::GpuDataManager::GetInstance()->HardwareAccelerationEnabled()) { if (content::GpuDataManager::GetInstance()->HardwareAccelerationEnabled()) {
video_consumer_.reset(new OffScreenVideoConsumer( video_consumer_.reset(new OffScreenVideoConsumer(
this, base::Bind(&OffScreenRenderWidgetHostView::OnPaint, this, base::BindRepeating(&OffScreenRenderWidgetHostView::OnPaint,
weak_ptr_factory_.GetWeakPtr()))); weak_ptr_factory_.GetWeakPtr())));
video_consumer_->SetActive(IsPainting()); video_consumer_->SetActive(IsPainting());
video_consumer_->SetFrameRate(GetFrameRate()); video_consumer_->SetFrameRate(GetFrameRate());
} }
@ -503,8 +503,8 @@ void OffScreenRenderWidgetHostView::InitAsPopup(
parent_host_view_->set_popup_host_view(this); parent_host_view_->set_popup_host_view(this);
parent_callback_ = parent_callback_ =
base::Bind(&OffScreenRenderWidgetHostView::OnPopupPaint, base::BindRepeating(&OffScreenRenderWidgetHostView::OnPopupPaint,
parent_host_view_->weak_ptr_factory_.GetWeakPtr()); parent_host_view_->weak_ptr_factory_.GetWeakPtr());
popup_position_ = pos; popup_position_ = pos;
@ -741,8 +741,8 @@ OffScreenRenderWidgetHostView::CreateHostDisplayClient(
ui::Compositor* compositor) { ui::Compositor* compositor) {
host_display_client_ = new OffScreenHostDisplayClient( host_display_client_ = new OffScreenHostDisplayClient(
gfx::kNullAcceleratedWidget, gfx::kNullAcceleratedWidget,
base::Bind(&OffScreenRenderWidgetHostView::OnPaint, base::BindRepeating(&OffScreenRenderWidgetHostView::OnPaint,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
host_display_client_->SetActive(IsPainting()); host_display_client_->SetActive(IsPainting());
return base::WrapUnique(host_display_client_); return base::WrapUnique(host_display_client_);
} }
@ -1084,8 +1084,9 @@ void OffScreenRenderWidgetHostView::SetupFrameRate(bool force) {
} else { } else {
begin_frame_timer_.reset(new AtomBeginFrameTimer( begin_frame_timer_.reset(new AtomBeginFrameTimer(
frame_rate_threshold_us_, frame_rate_threshold_us_,
base::Bind(&OffScreenRenderWidgetHostView::OnBeginFrameTimerTick, base::BindRepeating(
weak_ptr_factory_.GetWeakPtr()))); &OffScreenRenderWidgetHostView::OnBeginFrameTimerTick,
weak_ptr_factory_.GetWeakPtr())));
} }
} }

View file

@ -48,12 +48,12 @@ void OnPointerLockResponse(content::WebContents* web_contents, bool allowed) {
web_contents->GotResponseToLockMouseRequest(allowed); web_contents->GotResponseToLockMouseRequest(allowed);
} }
void OnPermissionResponse(base::Callback<void(bool)> callback, void OnPermissionResponse(base::OnceCallback<void(bool)> callback,
blink::mojom::PermissionStatus status) { blink::mojom::PermissionStatus status) {
if (status == blink::mojom::PermissionStatus::GRANTED) if (status == blink::mojom::PermissionStatus::GRANTED)
callback.Run(true); std::move(callback).Run(true);
else else
callback.Run(false); std::move(callback).Run(false);
} }
} // namespace } // namespace
@ -66,7 +66,7 @@ WebContentsPermissionHelper::~WebContentsPermissionHelper() {}
void WebContentsPermissionHelper::RequestPermission( void WebContentsPermissionHelper::RequestPermission(
content::PermissionType permission, content::PermissionType permission,
const base::RepeatingCallback<void(bool)>& callback, base::OnceCallback<void(bool)> callback,
bool user_gesture, bool user_gesture,
const base::DictionaryValue* details) { const base::DictionaryValue* details) {
auto* rfh = web_contents_->GetMainFrame(); auto* rfh = web_contents_->GetMainFrame();
@ -75,7 +75,7 @@ void WebContentsPermissionHelper::RequestPermission(
auto origin = web_contents_->GetLastCommittedURL(); auto origin = web_contents_->GetLastCommittedURL();
permission_manager->RequestPermissionWithDetails( permission_manager->RequestPermissionWithDetails(
permission, rfh, origin, false, details, permission, rfh, origin, false, details,
base::BindRepeating(&OnPermissionResponse, callback)); base::BindOnce(&OnPermissionResponse, std::move(callback)));
} }
bool WebContentsPermissionHelper::CheckPermission( bool WebContentsPermissionHelper::CheckPermission(
@ -90,10 +90,10 @@ bool WebContentsPermissionHelper::CheckPermission(
} }
void WebContentsPermissionHelper::RequestFullscreenPermission( void WebContentsPermissionHelper::RequestFullscreenPermission(
const base::Callback<void(bool)>& callback) { base::OnceCallback<void(bool)> callback) {
RequestPermission( RequestPermission(
static_cast<content::PermissionType>(PermissionType::FULLSCREEN), static_cast<content::PermissionType>(PermissionType::FULLSCREEN),
callback); std::move(callback));
} }
void WebContentsPermissionHelper::RequestMediaAccessPermission( void WebContentsPermissionHelper::RequestMediaAccessPermission(
@ -121,26 +121,27 @@ void WebContentsPermissionHelper::RequestMediaAccessPermission(
} }
void WebContentsPermissionHelper::RequestWebNotificationPermission( void WebContentsPermissionHelper::RequestWebNotificationPermission(
const base::RepeatingCallback<void(bool)>& callback) { base::OnceCallback<void(bool)> callback) {
RequestPermission(content::PermissionType::NOTIFICATIONS, callback); RequestPermission(content::PermissionType::NOTIFICATIONS,
std::move(callback));
} }
void WebContentsPermissionHelper::RequestPointerLockPermission( void WebContentsPermissionHelper::RequestPointerLockPermission(
bool user_gesture) { bool user_gesture) {
RequestPermission( RequestPermission(
static_cast<content::PermissionType>(PermissionType::POINTER_LOCK), static_cast<content::PermissionType>(PermissionType::POINTER_LOCK),
base::BindRepeating(&OnPointerLockResponse, web_contents_), user_gesture); base::BindOnce(&OnPointerLockResponse, web_contents_), user_gesture);
} }
void WebContentsPermissionHelper::RequestOpenExternalPermission( void WebContentsPermissionHelper::RequestOpenExternalPermission(
const base::RepeatingCallback<void(bool)>& callback, base::OnceCallback<void(bool)> callback,
bool user_gesture, bool user_gesture,
const GURL& url) { const GURL& url) {
base::DictionaryValue details; base::DictionaryValue details;
details.SetString("externalURL", url.spec()); details.SetString("externalURL", url.spec());
RequestPermission( RequestPermission(
static_cast<content::PermissionType>(PermissionType::OPEN_EXTERNAL), static_cast<content::PermissionType>(PermissionType::OPEN_EXTERNAL),
callback, user_gesture, &details); std::move(callback), user_gesture, &details);
} }
bool WebContentsPermissionHelper::CheckMediaAccessPermission( bool WebContentsPermissionHelper::CheckMediaAccessPermission(

View file

@ -25,17 +25,15 @@ class WebContentsPermissionHelper
}; };
// Asynchronous Requests // Asynchronous Requests
void RequestFullscreenPermission( void RequestFullscreenPermission(base::OnceCallback<void(bool)> callback);
const base::RepeatingCallback<void(bool)>& callback);
void RequestMediaAccessPermission(const content::MediaStreamRequest& request, void RequestMediaAccessPermission(const content::MediaStreamRequest& request,
content::MediaResponseCallback callback); content::MediaResponseCallback callback);
void RequestWebNotificationPermission( void RequestWebNotificationPermission(
const base::RepeatingCallback<void(bool)>& callback); base::OnceCallback<void(bool)> callback);
void RequestPointerLockPermission(bool user_gesture); void RequestPointerLockPermission(bool user_gesture);
void RequestOpenExternalPermission( void RequestOpenExternalPermission(base::OnceCallback<void(bool)> callback,
const base::RepeatingCallback<void(bool)>& callback, bool user_gesture,
bool user_gesture, const GURL& url);
const GURL& url);
// Synchronous Checks // Synchronous Checks
bool CheckMediaAccessPermission(const GURL& security_origin, bool CheckMediaAccessPermission(const GURL& security_origin,
@ -46,7 +44,7 @@ class WebContentsPermissionHelper
friend class content::WebContentsUserData<WebContentsPermissionHelper>; friend class content::WebContentsUserData<WebContentsPermissionHelper>;
void RequestPermission(content::PermissionType permission, void RequestPermission(content::PermissionType permission,
const base::RepeatingCallback<void(bool)>& callback, base::OnceCallback<void(bool)> callback,
bool user_gesture = false, bool user_gesture = false,
const base::DictionaryValue* details = nullptr); const base::DictionaryValue* details = nullptr);

View file

@ -11,7 +11,7 @@
#include "atom/browser/atom_browser_context.h" #include "atom/browser/atom_browser_context.h"
#include "atom/browser/native_window.h" #include "atom/browser/native_window.h"
#include "atom/browser/ui/file_dialog.h" #include "atom/browser/ui/file_dialog.h"
#include "atom/common/native_mate_converters/callback.h" #include "atom/common/native_mate_converters/once_callback.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/files/file_enumerator.h" #include "base/files/file_enumerator.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
@ -69,7 +69,8 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
ignore_result(handle->Then( ignore_result(handle->Then(
context, context,
v8::Local<v8::Function>::Cast(mate::ConvertToV8( v8::Local<v8::Function>::Cast(mate::ConvertToV8(
isolate, base::Bind(&FileSelectHelper::OnSaveDialogDone, this))))); isolate,
base::BindOnce(&FileSelectHelper::OnSaveDialogDone, this)))));
} }
void OnDirectoryListerDone(std::vector<FileChooserFileInfoPtr> file_info, void OnDirectoryListerDone(std::vector<FileChooserFileInfoPtr> file_info,

View file

@ -14,8 +14,9 @@ namespace mate {
// only ONCE in the program's whole lifetime, otherwise we would have memory // only ONCE in the program's whole lifetime, otherwise we would have memory
// leak. // leak.
template <typename T, typename Sig> template <typename T, typename Sig>
v8::Local<v8::Function> CreateConstructor(v8::Isolate* isolate, v8::Local<v8::Function> CreateConstructor(
const base::Callback<Sig>& func) { v8::Isolate* isolate,
const base::RepeatingCallback<Sig>& func) {
#ifndef NDEBUG #ifndef NDEBUG
static bool called = false; static bool called = false;
CHECK(!called) << "CreateConstructor can only be called for one type once"; CHECK(!called) << "CreateConstructor can only be called for one type once";

View file

@ -124,8 +124,9 @@ v8::Local<v8::Value> CreateFunctionFromTranslater(v8::Isolate* isolate,
bool one_time) { 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,
isolate, base::Bind(&CallTranslater))); mate::CreateFunctionTemplate(
isolate, base::BindRepeating(&CallTranslater)));
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);

View file

@ -56,8 +56,8 @@ v8::Local<v8::Value> MenuItemToV8(
v8_item.Set("submenu", v8_item.Set("submenu",
MenuToV8(isolate, web_contents, context, item.submenu)); MenuToV8(isolate, web_contents, context, item.submenu));
else if (item.action > 0) else if (item.action > 0)
v8_item.Set("click", v8_item.Set("click", base::BindRepeating(ExecuteCommand, web_contents,
base::Bind(ExecuteCommand, web_contents, item.action, context)); item.action, context));
return v8_item.GetHandle(); return v8_item.GetHandle();
} }

View file

@ -58,9 +58,9 @@ class ProcessSingleton {
// Chrome process was launched. Return true if the command line will be // Chrome process was launched. Return true if the command line will be
// handled within the current browser instance or false if the remote process // handled within the current browser instance or false if the remote process
// should handle it (i.e., because the current process is shutting down). // should handle it (i.e., because the current process is shutting down).
using NotificationCallback = using NotificationCallback = base::RepeatingCallback<bool(
base::Callback<bool(const base::CommandLine::StringVector& command_line, const base::CommandLine::StringVector& command_line,
const base::FilePath& current_directory)>; const base::FilePath& current_directory)>;
ProcessSingleton(const base::FilePath& user_data_dir, ProcessSingleton(const base::FilePath& user_data_dir,
const NotificationCallback& notification_callback); const NotificationCallback& notification_callback);
@ -94,7 +94,7 @@ class ProcessSingleton {
#if defined(OS_WIN) #if defined(OS_WIN)
// Called to query whether to kill a hung browser process that has visible // Called to query whether to kill a hung browser process that has visible
// windows. Return true to allow killing the hung process. // windows. Return true to allow killing the hung process.
using ShouldKillRemoteProcessCallback = base::Callback<bool()>; using ShouldKillRemoteProcessCallback = base::RepeatingCallback<bool()>;
void OverrideShouldKillRemoteProcessCallbackForTesting( void OverrideShouldKillRemoteProcessCallbackForTesting(
const ShouldKillRemoteProcessCallback& display_dialog_callback); const ShouldKillRemoteProcessCallback& display_dialog_callback);
#endif #endif
@ -120,7 +120,7 @@ class ProcessSingleton {
const base::TimeDelta& timeout); const base::TimeDelta& timeout);
void OverrideCurrentPidForTesting(base::ProcessId pid); void OverrideCurrentPidForTesting(base::ProcessId pid);
void OverrideKillCallbackForTesting( void OverrideKillCallbackForTesting(
const base::Callback<void(int)>& callback); const base::RepeatingCallback<void(int)>& callback);
#endif #endif
private: private:

View file

@ -482,8 +482,8 @@ class ProcessSingleton::LinuxWatcher
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Wait for reads. // Wait for reads.
fd_watch_controller_ = base::FileDescriptorWatcher::WatchReadable( fd_watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
fd, base::Bind(&SocketReader::OnSocketCanReadWithoutBlocking, fd, base::BindRepeating(&SocketReader::OnSocketCanReadWithoutBlocking,
base::Unretained(this))); base::Unretained(this)));
// If we haven't completed in a reasonable amount of time, give up. // If we haven't completed in a reasonable amount of time, give up.
timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds), timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds),
this, &SocketReader::CleanupAndDeleteSelf); this, &SocketReader::CleanupAndDeleteSelf);
@ -592,8 +592,8 @@ void ProcessSingleton::LinuxWatcher::StartListening(int socket) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Watch for client connections on this socket. // Watch for client connections on this socket.
socket_watcher_ = base::FileDescriptorWatcher::WatchReadable( socket_watcher_ = base::FileDescriptorWatcher::WatchReadable(
socket, base::Bind(&LinuxWatcher::OnSocketCanReadWithoutBlocking, socket, base::BindRepeating(&LinuxWatcher::OnSocketCanReadWithoutBlocking,
base::Unretained(this), socket)); base::Unretained(this), socket));
} }
void ProcessSingleton::LinuxWatcher::HandleMessage( void ProcessSingleton::LinuxWatcher::HandleMessage(
@ -686,8 +686,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
// Return to the UI thread to handle opening a new browser tab. // Return to the UI thread to handle opening a new browser tab.
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, base::Bind(&ProcessSingleton::LinuxWatcher::HandleMessage, FROM_HERE, base::BindOnce(&ProcessSingleton::LinuxWatcher::HandleMessage,
parent_, current_dir, tokens, this)); parent_, current_dir, tokens, this));
fd_watch_controller_.reset(); fd_watch_controller_.reset();
// LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader // LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader
@ -707,8 +707,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO}, FROM_HERE, {BrowserThread::IO},
base::Bind(&ProcessSingleton::LinuxWatcher::RemoveSocketReader, parent_, base::BindOnce(&ProcessSingleton::LinuxWatcher::RemoveSocketReader,
this)); parent_, this));
// We will be deleted once the posted RemoveSocketReader task runs. // We will be deleted once the posted RemoveSocketReader task runs.
} }
@ -728,8 +728,8 @@ ProcessSingleton::ProcessSingleton(
lock_path_ = user_data_dir.Append(kSingletonLockFilename); lock_path_ = user_data_dir.Append(kSingletonLockFilename);
cookie_path_ = user_data_dir.Append(kSingletonCookieFilename); cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);
kill_callback_ = kill_callback_ = base::BindRepeating(&ProcessSingleton::KillProcess,
base::Bind(&ProcessSingleton::KillProcess, base::Unretained(this)); base::Unretained(this));
} }
ProcessSingleton::~ProcessSingleton() { ProcessSingleton::~ProcessSingleton() {
@ -887,8 +887,8 @@ void ProcessSingleton::StartListeningOnSocket() {
watcher_ = new LinuxWatcher(this); watcher_ = new LinuxWatcher(this);
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::IO}, FROM_HERE, {BrowserThread::IO},
base::Bind(&ProcessSingleton::LinuxWatcher::StartListening, watcher_, base::BindOnce(&ProcessSingleton::LinuxWatcher::StartListening, watcher_,
sock_)); sock_));
} }
void ProcessSingleton::OnBrowserReady() { void ProcessSingleton::OnBrowserReady() {
@ -950,7 +950,7 @@ void ProcessSingleton::OverrideCurrentPidForTesting(base::ProcessId pid) {
} }
void ProcessSingleton::OverrideKillCallbackForTesting( void ProcessSingleton::OverrideKillCallbackForTesting(
const base::Callback<void(int)>& callback) { const base::RepeatingCallback<void(int)>& callback) {
kill_callback_ = callback; kill_callback_ = callback;
} }

View file

@ -176,7 +176,8 @@ ProcessSingleton::ProcessSingleton(
is_virtualized_(false), is_virtualized_(false),
lock_file_(INVALID_HANDLE_VALUE), lock_file_(INVALID_HANDLE_VALUE),
user_data_dir_(user_data_dir), user_data_dir_(user_data_dir),
should_kill_remote_process_callback_(base::Bind(&TerminateAppWithError)) { should_kill_remote_process_callback_(
base::BindRepeating(&TerminateAppWithError)) {
// The user_data_dir may have not been created yet. // The user_data_dir may have not been created yet.
base::CreateDirectoryAndGetError(user_data_dir, nullptr); base::CreateDirectoryAndGetError(user_data_dir, nullptr);
} }
@ -290,9 +291,10 @@ bool ProcessSingleton::Create() {
if (lock_file_ != INVALID_HANDLE_VALUE) { if (lock_file_ != INVALID_HANDLE_VALUE) {
// Set the window's title to the path of our user data directory so // Set the window's title to the path of our user data directory so
// other Chrome instances can decide if they should forward to us. // other Chrome instances can decide if they should forward to us.
bool result = window_.CreateNamed( bool result =
base::Bind(&ProcessLaunchNotification, notification_callback_), window_.CreateNamed(base::BindRepeating(&ProcessLaunchNotification,
user_data_dir_.value()); notification_callback_),
user_data_dir_.value());
// NB: Ensure that if the primary app gets started as elevated // NB: Ensure that if the primary app gets started as elevated
// admin inadvertently, secondary windows running not as elevated // admin inadvertently, secondary windows running not as elevated