Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_ | |
| 6 #define UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "ui/display/chromeos/configure_displays_task.h" | |
| 12 #include "ui/display/chromeos/display_configurator.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 | |
| 16 class DisplaySnapshot; | |
| 17 class NativeDisplayDelegate; | |
| 18 | |
| 19 class DISPLAY_EXPORT UpdateDisplayConfigurationTask { | |
| 20 public: | |
| 21 typedef base::Callback<void( | |
| 22 bool /* success */, | |
| 23 const std::vector<DisplayConfigurator::DisplayState>& /* displays */, | |
| 24 const gfx::Size& /* framebuffer_size */, | |
| 25 MultipleDisplayState /* new_display_state */, | |
| 26 chromeos::DisplayPowerState /* new_power_state */)> ResponseCallback; | |
| 27 | |
| 28 UpdateDisplayConfigurationTask( | |
| 29 NativeDisplayDelegate* delegate, | |
| 30 DisplayConfigurator::DisplayLayoutManager* layout_manager, | |
| 31 MultipleDisplayState new_display_state, | |
| 32 chromeos::DisplayPowerState new_power_state, | |
| 33 int power_flags, | |
| 34 uint32_t background_color_argb, | |
| 35 bool force_configure, | |
| 36 const ResponseCallback& callback); | |
| 37 ~UpdateDisplayConfigurationTask(); | |
| 38 | |
| 39 void Run(); | |
| 40 | |
| 41 private: | |
| 42 // Callback to NativeDisplayDelegate::GetDisplays(). | |
| 43 void OnDisplaysUpdated(const std::vector<DisplaySnapshot*>& displays); | |
| 44 | |
| 45 // Callback to ConfigureDisplaysTask used to process the result of a display | |
| 46 // configuration run. | |
| 47 void OnStateEntered(ConfigureDisplaysTask::Status status); | |
| 48 | |
| 49 // If the initial display configuration run failed due to errors entering | |
| 50 // mirror more, another configuration run is executed to enter software | |
| 51 // mirroring. This is the callback used to process the result of that | |
| 52 // configuration. | |
| 53 void OnEnableSoftwareMirroring(ConfigureDisplaysTask::Status status); | |
| 54 | |
| 55 // Starts the configuration process. |callback| is used to continue the task | |
| 56 // after |configure_taks_| finishes executing. | |
| 57 void EnterState(const ConfigureDisplaysTask::ResponseCallback& callback); | |
| 58 | |
| 59 // Finishes display configuration and runs |callback_|. | |
| 60 void FinishConfiguration(bool success); | |
| 61 | |
| 62 // Returns true if the DPMS state should be force to on. | |
| 63 bool ShouldForceDpms() const; | |
| 64 | |
| 65 // Returns true if a display configuration is required. | |
| 66 bool ShouldConfigure() const; | |
| 67 | |
| 68 // Returns a display state based on the power state. | |
| 69 MultipleDisplayState ChooseDisplayState() const; | |
| 70 | |
| 71 NativeDisplayDelegate* delegate_; // Not owned. | |
| 72 DisplayConfigurator::DisplayLayoutManager* layout_manager_; // Not owned. | |
| 73 | |
| 74 // Requested display state. | |
| 75 MultipleDisplayState new_display_state_; | |
| 76 | |
| 77 // Requested power state. | |
| 78 chromeos::DisplayPowerState new_power_state_; | |
| 79 | |
| 80 int power_flags_; | |
|
Daniel Erat
2014/12/11 23:34:07
nit: either document the flags here or point at th
| |
| 81 | |
| 82 uint32_t background_color_argb_; | |
| 83 | |
| 84 bool force_configure_; | |
| 85 | |
| 86 // Used to signal that the task has finished. | |
| 87 ResponseCallback callback_; | |
| 88 | |
| 89 bool force_dpms_; | |
| 90 | |
| 91 // List of updated displays. | |
| 92 std::vector<DisplayConfigurator::DisplayState> cached_displays_; | |
| 93 | |
| 94 gfx::Size framebuffer_size_; | |
| 95 | |
| 96 scoped_ptr<ConfigureDisplaysTask> configure_task_; | |
| 97 | |
| 98 base::WeakPtrFactory<UpdateDisplayConfigurationTask> weak_ptr_factory_; | |
| 99 | |
| 100 DISALLOW_COPY_AND_ASSIGN(UpdateDisplayConfigurationTask); | |
| 101 }; | |
| 102 | |
| 103 } // namespace ui | |
| 104 | |
| 105 #endif // UI_DISPLAY_CHROMEOS_UPDATE_DISPLAY_CONFIGURATION_TASK_H_ | |
| OLD | NEW |