Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: ui/display/chromeos/display_configurator.h

Issue 886103002: Make SetDisplayPower() take a callback to signal completion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/display/chromeos/display_configurator.h
diff --git a/ui/display/chromeos/display_configurator.h b/ui/display/chromeos/display_configurator.h
index b35ce4ece75b8c251b56dd404487234cff44386a..db4fc5f4fed2e182e3a8b9940e75440bde2a8f6d 100644
--- a/ui/display/chromeos/display_configurator.h
+++ b/ui/display/chromeos/display_configurator.h
@@ -40,6 +40,8 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
typedef uint64_t ContentProtectionClientId;
static const ContentProtectionClientId kInvalidClientId = 0;
+ typedef base::Callback<void(bool)> ConfigurationCallback;
+
struct DisplayState {
DisplayState();
@@ -222,9 +224,12 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// Called when powerd notifies us that some set of displays should be turned
// on or off. This requires enabling or disabling the CRTC associated with
// the display(s) in question so that the low power state is engaged.
- // |flags| contains bitwise-or-ed kSetDisplayPower* values. Returns true if
- // the system successfully enters (or was already in) |power_state|.
- void SetDisplayPower(chromeos::DisplayPowerState power_state, int flags);
+ // |flags| contains bitwise-or-ed kSetDisplayPower* values. After the
+ // configuration finishes |callback| is called with the status of the
+ // operation.
+ void SetDisplayPower(chromeos::DisplayPowerState power_state,
+ int flags,
+ const ConfigurationCallback& callback);
// Force switching the display mode to |new_state|. Returns false if
// switching failed (possibly because |new_state| is invalid for the
@@ -334,6 +339,13 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// otherwise.
bool ShouldRunConfigurationTask() const;
+ // Helper functions which will call the callbacks in
+ // |pending_configuration_callbacks_| and |queued_configuration_callbacks_|
+ // and clear the lists after. |success| is the configuration status used when
+ // calling the callbacks.
+ void CallAndClearPendingCallbacks(bool success);
+ void CallAndClearQueuedCallbacks(bool success);
+
StateController* state_controller_;
SoftwareMirroringController* mirroring_controller_;
scoped_ptr<NativeDisplayDelegate> native_display_delegate_;
@@ -367,6 +379,15 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// Bitwise-or value of the |kSetDisplayPower*| flags defined above.
int requested_power_flags_;
+ // List of callbacks from callers waiting for the display configuration to
+ // start/finish. Note these callbacks belong to pending request not a
Daniel Erat 2015/01/30 17:14:07 the use of "pending" here is pretty confusing give
dnicoara 2015/01/30 18:25:28 Done.
+ // request currently active.
+ std::vector<ConfigurationCallback> queued_configuration_callbacks_;
+
+ // List of callbacks belonging to the currently running display configuration
+ // task.
+ std::vector<ConfigurationCallback> pending_configuration_callbacks_;
+
// True if the caller wants to force the display configuration process.
bool force_configure_;

Powered by Google App Engine
This is Rietveld 408576698