Commit 5fe41d91 authored by tzik's avatar tzik Committed by Commit Bot

Use OnceCallback on Mojo interfaces in services/ui/public

This CL flips `use_once_callback` flag on the Mojo code generator for
//services/ui/public, and fixes all compile errors after that. After
this CL, Mojo interfaces there service starts using base::OnceCallback
instead of base::Callback on its return value handling.

Bug: 714018
Change-Id: I9a0923249f3bb2b37319a118f742f384c90cf31f
Reviewed-on: https://chromium-review.googlesource.com/1151185Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578759}
parent 184a37de
...@@ -18,17 +18,17 @@ OutputProtection::~OutputProtection() { ...@@ -18,17 +18,17 @@ OutputProtection::~OutputProtection() {
void OutputProtection::QueryContentProtectionStatus( void OutputProtection::QueryContentProtectionStatus(
int64_t display_id, int64_t display_id,
const QueryContentProtectionStatusCallback& callback) { QueryContentProtectionStatusCallback callback) {
display_configurator_->QueryContentProtectionStatus(client_id_, display_id, display_configurator_->QueryContentProtectionStatus(client_id_, display_id,
callback); std::move(callback));
} }
void OutputProtection::SetContentProtection( void OutputProtection::SetContentProtection(
int64_t display_id, int64_t display_id,
uint32_t desired_method_mask, uint32_t desired_method_mask,
const SetContentProtectionCallback& callback) { SetContentProtectionCallback callback) {
display_configurator_->SetContentProtection(client_id_, display_id, display_configurator_->SetContentProtection(
desired_method_mask, callback); client_id_, display_id, desired_method_mask, std::move(callback));
} }
} // namespace display } // namespace display
...@@ -24,11 +24,10 @@ class OutputProtection : public mojom::OutputProtection { ...@@ -24,11 +24,10 @@ class OutputProtection : public mojom::OutputProtection {
// mojom::OutputProtection: // mojom::OutputProtection:
void QueryContentProtectionStatus( void QueryContentProtectionStatus(
int64_t display_id, int64_t display_id,
const QueryContentProtectionStatusCallback& callback) override; QueryContentProtectionStatusCallback callback) override;
void SetContentProtection( void SetContentProtection(int64_t display_id,
int64_t display_id, uint32_t desired_method_mask,
uint32_t desired_method_mask, SetContentProtectionCallback callback) override;
const SetContentProtectionCallback& callback) override;
private: private:
DisplayConfigurator* const display_configurator_; DisplayConfigurator* const display_configurator_;
......
...@@ -241,13 +241,13 @@ void ScreenManagerOzoneInternal::SetDisplayWorkArea(int64_t display_id, ...@@ -241,13 +241,13 @@ void ScreenManagerOzoneInternal::SetDisplayWorkArea(int64_t display_id,
} }
void ScreenManagerOzoneInternal::TakeDisplayControl( void ScreenManagerOzoneInternal::TakeDisplayControl(
const TakeDisplayControlCallback& callback) { TakeDisplayControlCallback callback) {
display_configurator_.TakeControl(callback); display_configurator_.TakeControl(std::move(callback));
} }
void ScreenManagerOzoneInternal::RelinquishDisplayControl( void ScreenManagerOzoneInternal::RelinquishDisplayControl(
const RelinquishDisplayControlCallback& callback) { RelinquishDisplayControlCallback callback) {
display_configurator_.RelinquishControl(callback); display_configurator_.RelinquishControl(std::move(callback));
} }
void ScreenManagerOzoneInternal::OnDisplayAdded(const Display& display) { void ScreenManagerOzoneInternal::OnDisplayAdded(const Display& display) {
......
...@@ -64,9 +64,9 @@ class ScreenManagerOzoneInternal : public ScreenManager, ...@@ -64,9 +64,9 @@ class ScreenManagerOzoneInternal : public ScreenManager,
void SetDisplayWorkArea(int64_t display_id, void SetDisplayWorkArea(int64_t display_id,
const gfx::Size& size, const gfx::Size& size,
const gfx::Insets& insets) override; const gfx::Insets& insets) override;
void TakeDisplayControl(const TakeDisplayControlCallback& callback) override; void TakeDisplayControl(TakeDisplayControlCallback callback) override;
void RelinquishDisplayControl( void RelinquishDisplayControl(
const RelinquishDisplayControlCallback& callback) override; RelinquishDisplayControlCallback callback) override;
private: private:
friend class ScreenManagerOzoneInternalTest; friend class ScreenManagerOzoneInternalTest;
......
...@@ -13,7 +13,4 @@ mojom("display") { ...@@ -13,7 +13,4 @@ mojom("display") {
public_deps = [ public_deps = [
"//ui/gfx/geometry/mojo", "//ui/gfx/geometry/mojo",
] ]
# TODO(crbug.com/714018): Convert the implementation to use OnceCallback.
use_once_callback = false
} }
...@@ -552,12 +552,12 @@ DisplayConfigurator::~DisplayConfigurator() { ...@@ -552,12 +552,12 @@ DisplayConfigurator::~DisplayConfigurator() {
CallAndClearQueuedCallbacks(false); CallAndClearQueuedCallbacks(false);
while (!query_protection_callbacks_.empty()) { while (!query_protection_callbacks_.empty()) {
query_protection_callbacks_.front().Run(false, 0, 0); std::move(query_protection_callbacks_.front()).Run(false, 0, 0);
query_protection_callbacks_.pop(); query_protection_callbacks_.pop();
} }
while (!set_protection_callbacks_.empty()) { while (!set_protection_callbacks_.empty()) {
set_protection_callbacks_.front().Run(false); std::move(set_protection_callbacks_.front()).Run(false);
set_protection_callbacks_.pop(); set_protection_callbacks_.pop();
} }
} }
...@@ -757,7 +757,7 @@ void DisplayConfigurator::OnContentProtectionClientUnregistered(bool success) { ...@@ -757,7 +757,7 @@ void DisplayConfigurator::OnContentProtectionClientUnregistered(bool success) {
content_protection_tasks_.pop(); content_protection_tasks_.pop();
DCHECK(!set_protection_callbacks_.empty()); DCHECK(!set_protection_callbacks_.empty());
SetProtectionCallback callback = set_protection_callbacks_.front(); SetProtectionCallback callback = std::move(set_protection_callbacks_.front());
set_protection_callbacks_.pop(); set_protection_callbacks_.pop();
if (!content_protection_tasks_.empty()) if (!content_protection_tasks_.empty())
...@@ -767,23 +767,23 @@ void DisplayConfigurator::OnContentProtectionClientUnregistered(bool success) { ...@@ -767,23 +767,23 @@ void DisplayConfigurator::OnContentProtectionClientUnregistered(bool success) {
void DisplayConfigurator::QueryContentProtectionStatus( void DisplayConfigurator::QueryContentProtectionStatus(
uint64_t client_id, uint64_t client_id,
int64_t display_id, int64_t display_id,
const QueryProtectionCallback& callback) { QueryProtectionCallback callback) {
// Exclude virtual displays so that protected content will not be recaptured // Exclude virtual displays so that protected content will not be recaptured
// through the cast stream. // through the cast stream.
for (const DisplaySnapshot* display : cached_displays_) { for (const DisplaySnapshot* display : cached_displays_) {
if (display->display_id() == display_id && if (display->display_id() == display_id &&
!IsPhysicalDisplayType(display->type())) { !IsPhysicalDisplayType(display->type())) {
callback.Run(false, 0, 0); std::move(callback).Run(false, 0, 0);
return; return;
} }
} }
if (!configure_display_ || display_externally_controlled_) { if (!configure_display_ || display_externally_controlled_) {
callback.Run(false, 0, 0); std::move(callback).Run(false, 0, 0);
return; return;
} }
query_protection_callbacks_.push(callback); query_protection_callbacks_.push(std::move(callback));
QueryContentProtectionTask* task = new QueryContentProtectionTask( QueryContentProtectionTask* task = new QueryContentProtectionTask(
layout_manager_.get(), native_display_delegate_.get(), display_id, layout_manager_.get(), native_display_delegate_.get(), display_id,
base::Bind(&DisplayConfigurator::OnContentProtectionQueried, base::Bind(&DisplayConfigurator::OnContentProtectionQueried,
...@@ -816,21 +816,21 @@ void DisplayConfigurator::OnContentProtectionQueried( ...@@ -816,21 +816,21 @@ void DisplayConfigurator::OnContentProtectionQueried(
content_protection_tasks_.pop(); content_protection_tasks_.pop();
DCHECK(!query_protection_callbacks_.empty()); DCHECK(!query_protection_callbacks_.empty());
QueryProtectionCallback callback = query_protection_callbacks_.front(); QueryProtectionCallback callback =
std::move(query_protection_callbacks_.front());
query_protection_callbacks_.pop(); query_protection_callbacks_.pop();
callback.Run(success, link_mask, protection_mask); std::move(callback).Run(success, link_mask, protection_mask);
if (!content_protection_tasks_.empty()) if (!content_protection_tasks_.empty())
content_protection_tasks_.front().Run(); content_protection_tasks_.front().Run();
} }
void DisplayConfigurator::SetContentProtection( void DisplayConfigurator::SetContentProtection(uint64_t client_id,
uint64_t client_id, int64_t display_id,
int64_t display_id, uint32_t desired_method_mask,
uint32_t desired_method_mask, SetProtectionCallback callback) {
const SetProtectionCallback& callback) {
if (!configure_display_ || display_externally_controlled_) { if (!configure_display_ || display_externally_controlled_) {
callback.Run(false); std::move(callback).Run(false);
return; return;
} }
...@@ -846,7 +846,7 @@ void DisplayConfigurator::SetContentProtection( ...@@ -846,7 +846,7 @@ void DisplayConfigurator::SetContentProtection(
} }
protections[display_id] |= desired_method_mask; protections[display_id] |= desired_method_mask;
set_protection_callbacks_.push(callback); set_protection_callbacks_.push(std::move(callback));
ApplyContentProtectionTask* task = new ApplyContentProtectionTask( ApplyContentProtectionTask* task = new ApplyContentProtectionTask(
layout_manager_.get(), native_display_delegate_.get(), protections, layout_manager_.get(), native_display_delegate_.get(), protections,
base::Bind(&DisplayConfigurator::OnSetContentProtectionCompleted, base::Bind(&DisplayConfigurator::OnSetContentProtectionCompleted,
...@@ -867,11 +867,11 @@ void DisplayConfigurator::OnSetContentProtectionCompleted( ...@@ -867,11 +867,11 @@ void DisplayConfigurator::OnSetContentProtectionCompleted(
content_protection_tasks_.pop(); content_protection_tasks_.pop();
DCHECK(!set_protection_callbacks_.empty()); DCHECK(!set_protection_callbacks_.empty());
SetProtectionCallback callback = set_protection_callbacks_.front(); SetProtectionCallback callback = std::move(set_protection_callbacks_.front());
set_protection_callbacks_.pop(); set_protection_callbacks_.pop();
if (!success) { if (!success) {
callback.Run(false); std::move(callback).Run(false);
return; return;
} }
...@@ -886,7 +886,7 @@ void DisplayConfigurator::OnSetContentProtectionCompleted( ...@@ -886,7 +886,7 @@ void DisplayConfigurator::OnSetContentProtectionCompleted(
client_protection_requests_[client_id][display_id] = desired_method_mask; client_protection_requests_[client_id][display_id] = desired_method_mask;
} }
callback.Run(true); std::move(callback).Run(true);
if (!content_protection_tasks_.empty()) if (!content_protection_tasks_.empty())
content_protection_tasks_.front().Run(); content_protection_tasks_.front().Run();
} }
......
...@@ -49,16 +49,16 @@ class DISPLAY_MANAGER_EXPORT DisplayConfigurator ...@@ -49,16 +49,16 @@ class DISPLAY_MANAGER_EXPORT DisplayConfigurator
using ConfigurationCallback = base::Callback<void(bool /* success */)>; using ConfigurationCallback = base::Callback<void(bool /* success */)>;
using SetProtectionCallback = base::Callback<void(bool /* success */)>; using SetProtectionCallback = base::OnceCallback<void(bool /* success */)>;
// link_mask: The type of connected display links, which is a bitmask of // link_mask: The type of connected display links, which is a bitmask of
// DisplayConnectionType values. // DisplayConnectionType values.
// protection_mask: The desired protection methods, which is a bitmask of the // protection_mask: The desired protection methods, which is a bitmask of the
// ContentProtectionMethod values. // ContentProtectionMethod values.
using QueryProtectionCallback = using QueryProtectionCallback =
base::Callback<void(bool /* success */, base::OnceCallback<void(bool /* success */,
uint32_t /* link_mask */, uint32_t /* link_mask */,
uint32_t /* protection_mask */)>; uint32_t /* protection_mask */)>;
using DisplayControlCallback = base::OnceCallback<void(bool /* success */)>; using DisplayControlCallback = base::OnceCallback<void(bool /* success */)>;
using DisplayStateList = std::vector<DisplaySnapshot*>; using DisplayStateList = std::vector<DisplaySnapshot*>;
...@@ -273,7 +273,7 @@ class DISPLAY_MANAGER_EXPORT DisplayConfigurator ...@@ -273,7 +273,7 @@ class DISPLAY_MANAGER_EXPORT DisplayConfigurator
// to the query. // to the query.
void QueryContentProtectionStatus(uint64_t client_id, void QueryContentProtectionStatus(uint64_t client_id,
int64_t display_id, int64_t display_id,
const QueryProtectionCallback& callback); QueryProtectionCallback callback);
// Requests the desired protection methods. // Requests the desired protection methods.
// |protection_mask| is the desired protection methods, which is a bitmask // |protection_mask| is the desired protection methods, which is a bitmask
...@@ -282,7 +282,7 @@ class DISPLAY_MANAGER_EXPORT DisplayConfigurator ...@@ -282,7 +282,7 @@ class DISPLAY_MANAGER_EXPORT DisplayConfigurator
void SetContentProtection(uint64_t client_id, void SetContentProtection(uint64_t client_id,
int64_t display_id, int64_t display_id,
uint32_t protection_mask, uint32_t protection_mask,
const SetProtectionCallback& callback); SetProtectionCallback callback);
// Returns true if there is at least one display on. // Returns true if there is at least one display on.
bool IsDisplayOn() const; bool IsDisplayOn() const;
......
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