Commit 42437ff7 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Web Payment] Modern disallow and more private members.

Before this patch, the classes in payment_app_provider_impl.h/cc used a
combination of the deprecated DISALLOW_COPY_AND_ASSIGN and not
specifying copying behavior.

This patch removes DISALLOW_COPY_AND_ASSIGN and instead explicitly
deletes the copy constructor and assign operator in
payment_app_provider_impl.h/cc.

After this patch, the classes in payment_app_provider_impl.h/cc use the
current style of explicitly deleting their copy constructor and assign
operator.

Bug: 1005076
Change-Id: Ibae5b145927e2fd8e1e751605caf4aaa49b41ce4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090491
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748733}
parent 0a74021a
...@@ -82,6 +82,12 @@ class InvokePaymentAppCallbackRepository { ...@@ -82,6 +82,12 @@ class InvokePaymentAppCallbackRepository {
return base::Singleton<InvokePaymentAppCallbackRepository>::get(); return base::Singleton<InvokePaymentAppCallbackRepository>::get();
} }
// Disallow copy and assign.
InvokePaymentAppCallbackRepository(
const InvokePaymentAppCallbackRepository& other) = delete;
InvokePaymentAppCallbackRepository& operator=(
const InvokePaymentAppCallbackRepository& other) = delete;
RespondWithCallbacks* GetCallback(BrowserContext* browser_context) { RespondWithCallbacks* GetCallback(BrowserContext* browser_context) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
auto it = invoke_callbacks_.find(browser_context); auto it = invoke_callbacks_.find(browser_context);
...@@ -103,8 +109,8 @@ class InvokePaymentAppCallbackRepository { ...@@ -103,8 +109,8 @@ class InvokePaymentAppCallbackRepository {
} }
private: private:
InvokePaymentAppCallbackRepository() {} InvokePaymentAppCallbackRepository() = default;
~InvokePaymentAppCallbackRepository() {} ~InvokePaymentAppCallbackRepository() = default;
friend struct base::DefaultSingletonTraits< friend struct base::DefaultSingletonTraits<
InvokePaymentAppCallbackRepository>; InvokePaymentAppCallbackRepository>;
...@@ -146,6 +152,10 @@ class RespondWithCallbacks : public PaymentHandlerResponseCallback { ...@@ -146,6 +152,10 @@ class RespondWithCallbacks : public PaymentHandlerResponseCallback {
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
// Disallow copy and assign.
RespondWithCallbacks(const RespondWithCallbacks& other) = delete;
RespondWithCallbacks& operator=(const RespondWithCallbacks& other) = delete;
mojo::PendingRemote<PaymentHandlerResponseCallback> mojo::PendingRemote<PaymentHandlerResponseCallback>
BindNewPipeAndPassRemote() { BindNewPipeAndPassRemote() {
return receiver_.BindNewPipeAndPassRemote(); return receiver_.BindNewPipeAndPassRemote();
...@@ -239,7 +249,7 @@ class RespondWithCallbacks : public PaymentHandlerResponseCallback { ...@@ -239,7 +249,7 @@ class RespondWithCallbacks : public PaymentHandlerResponseCallback {
} }
private: private:
~RespondWithCallbacks() override {} ~RespondWithCallbacks() override = default;
void ClearCallbackRepositoryAndCloseWindow() { void ClearCallbackRepositoryAndCloseWindow() {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
...@@ -266,8 +276,6 @@ class RespondWithCallbacks : public PaymentHandlerResponseCallback { ...@@ -266,8 +276,6 @@ class RespondWithCallbacks : public PaymentHandlerResponseCallback {
mojo::Receiver<PaymentHandlerResponseCallback> receiver_{this}; mojo::Receiver<PaymentHandlerResponseCallback> receiver_{this};
base::WeakPtrFactory<RespondWithCallbacks> weak_ptr_factory_{this}; base::WeakPtrFactory<RespondWithCallbacks> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(RespondWithCallbacks);
}; };
void DidGetAllPaymentAppsOnCoreThread( void DidGetAllPaymentAppsOnCoreThread(
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_PROVIDER_IMPL_H_ #ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_PROVIDER_IMPL_H_
#define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_PROVIDER_IMPL_H_ #define CONTENT_BROWSER_PAYMENTS_PAYMENT_APP_PROVIDER_IMPL_H_
#include "base/macros.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/payment_app_provider.h" #include "content/public/browser/payment_app_provider.h"
...@@ -17,6 +16,11 @@ class CONTENT_EXPORT PaymentAppProviderImpl : public PaymentAppProvider { ...@@ -17,6 +16,11 @@ class CONTENT_EXPORT PaymentAppProviderImpl : public PaymentAppProvider {
public: public:
static PaymentAppProviderImpl* GetInstance(); static PaymentAppProviderImpl* GetInstance();
// Disallow copy and assign.
PaymentAppProviderImpl(const PaymentAppProviderImpl& other) = delete;
PaymentAppProviderImpl& operator=(const PaymentAppProviderImpl& other) =
delete;
// PaymentAppProvider implementation: // PaymentAppProvider implementation:
// Should be accessed only on the UI thread. // Should be accessed only on the UI thread.
void GetAllPaymentApps(BrowserContext* browser_context, void GetAllPaymentApps(BrowserContext* browser_context,
...@@ -75,8 +79,6 @@ class CONTENT_EXPORT PaymentAppProviderImpl : public PaymentAppProvider { ...@@ -75,8 +79,6 @@ class CONTENT_EXPORT PaymentAppProviderImpl : public PaymentAppProvider {
// Map to maintain at most one opened window per browser context. // Map to maintain at most one opened window per browser context.
std::map<BrowserContext*, std::unique_ptr<PaymentHandlerWindowObserver>> std::map<BrowserContext*, std::unique_ptr<PaymentHandlerWindowObserver>>
payment_handler_windows_; payment_handler_windows_;
DISALLOW_COPY_AND_ASSIGN(PaymentAppProviderImpl);
}; };
} // namespace content } // namespace content
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment