| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/display/chromeos/configure_displays_task.h" | 5 #include "ui/display/manager/chromeos/configure_displays_task.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "ui/display/chromeos/display_util.h" | 9 #include "ui/display/manager/chromeos/display_util.h" |
| 10 #include "ui/display/types/display_snapshot.h" | 10 #include "ui/display/types/display_snapshot.h" |
| 11 #include "ui/display/types/native_display_delegate.h" | 11 #include "ui/display/types/native_display_delegate.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Find the next best mode after |display_mode|. If none can be found return | 17 // Find the next best mode after |display_mode|. If none can be found return |
| 18 // nullptr. | 18 // nullptr. |
| 19 const DisplayMode* FindNextMode(const DisplaySnapshot& display_state, | 19 const DisplayMode* FindNextMode(const DisplaySnapshot& display_state, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 return best_mode; | 35 return best_mode; |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 DisplayConfigureRequest::DisplayConfigureRequest(DisplaySnapshot* display, | 40 DisplayConfigureRequest::DisplayConfigureRequest(DisplaySnapshot* display, |
| 41 const DisplayMode* mode, | 41 const DisplayMode* mode, |
| 42 const gfx::Point& origin) | 42 const gfx::Point& origin) |
| 43 : display(display), mode(mode), origin(origin) { | 43 : display(display), mode(mode), origin(origin) {} |
| 44 } | |
| 45 | 44 |
| 46 ConfigureDisplaysTask::ConfigureDisplaysTask( | 45 ConfigureDisplaysTask::ConfigureDisplaysTask( |
| 47 NativeDisplayDelegate* delegate, | 46 NativeDisplayDelegate* delegate, |
| 48 const std::vector<DisplayConfigureRequest>& requests, | 47 const std::vector<DisplayConfigureRequest>& requests, |
| 49 const ResponseCallback& callback) | 48 const ResponseCallback& callback) |
| 50 : delegate_(delegate), | 49 : delegate_(delegate), |
| 51 requests_(requests), | 50 requests_(requests), |
| 52 callback_(callback), | 51 callback_(callback), |
| 53 is_configuring_(false), | 52 is_configuring_(false), |
| 54 num_displays_configured_(0), | 53 num_displays_configured_(0), |
| 55 task_status_(SUCCESS), | 54 task_status_(SUCCESS), |
| 56 weak_ptr_factory_(this) { | 55 weak_ptr_factory_(this) { |
| 57 for (size_t i = 0; i < requests_.size(); ++i) | 56 for (size_t i = 0; i < requests_.size(); ++i) |
| 58 pending_request_indexes_.push(i); | 57 pending_request_indexes_.push(i); |
| 59 } | 58 } |
| 60 | 59 |
| 61 ConfigureDisplaysTask::~ConfigureDisplaysTask() { | 60 ConfigureDisplaysTask::~ConfigureDisplaysTask() {} |
| 62 } | |
| 63 | 61 |
| 64 void ConfigureDisplaysTask::Run() { | 62 void ConfigureDisplaysTask::Run() { |
| 65 // Synchronous configurators will recursively call Run(). In that case just | 63 // Synchronous configurators will recursively call Run(). In that case just |
| 66 // defer their call to the next iteration in the while-loop. This is done to | 64 // defer their call to the next iteration in the while-loop. This is done to |
| 67 // guard against stack overflows if the display has a large list of broken | 65 // guard against stack overflows if the display has a large list of broken |
| 68 // modes. | 66 // modes. |
| 69 if (is_configuring_) | 67 if (is_configuring_) |
| 70 return; | 68 return; |
| 71 | 69 |
| 72 { | 70 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 113 } |
| 116 | 114 |
| 117 num_displays_configured_++; | 115 num_displays_configured_++; |
| 118 if (!success) | 116 if (!success) |
| 119 task_status_ = ERROR; | 117 task_status_ = ERROR; |
| 120 | 118 |
| 121 Run(); | 119 Run(); |
| 122 } | 120 } |
| 123 | 121 |
| 124 } // namespace ui | 122 } // namespace ui |
| OLD | NEW |