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/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/types/display_snapshot.h" | 10 #include "ui/display/types/display_snapshot.h" |
10 #include "ui/display/types/native_display_delegate.h" | 11 #include "ui/display/types/native_display_delegate.h" |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 // 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 |
17 // nullptr. | 18 // nullptr. |
18 const DisplayMode* FindNextMode(const DisplaySnapshot& display_state, | 19 const DisplayMode* FindNextMode(const DisplaySnapshot& display_state, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // modes. | 68 // modes. |
68 if (is_configuring_) | 69 if (is_configuring_) |
69 return; | 70 return; |
70 | 71 |
71 { | 72 { |
72 base::AutoReset<bool> recursivity_guard(&is_configuring_, true); | 73 base::AutoReset<bool> recursivity_guard(&is_configuring_, true); |
73 while (!pending_request_indexes_.empty()) { | 74 while (!pending_request_indexes_.empty()) { |
74 size_t index = pending_request_indexes_.front(); | 75 size_t index = pending_request_indexes_.front(); |
75 DisplayConfigureRequest* request = &requests_[index]; | 76 DisplayConfigureRequest* request = &requests_[index]; |
76 pending_request_indexes_.pop(); | 77 pending_request_indexes_.pop(); |
77 delegate_->Configure(*request->display, request->mode, request->origin, | 78 // Non-native displays do not require configuration through the |
78 base::Bind(&ConfigureDisplaysTask::OnConfigured, | 79 // NativeDisplayDelegate. |
79 weak_ptr_factory_.GetWeakPtr(), index)); | 80 if (!IsNativeDisplay(request->display->type())) { |
| 81 OnConfigured(index, true); |
| 82 } else { |
| 83 delegate_->Configure(*request->display, request->mode, request->origin, |
| 84 base::Bind(&ConfigureDisplaysTask::OnConfigured, |
| 85 weak_ptr_factory_.GetWeakPtr(), index)); |
| 86 } |
80 } | 87 } |
81 } | 88 } |
82 | 89 |
83 // Nothing should be modified after the |callback_| is called since the | 90 // Nothing should be modified after the |callback_| is called since the |
84 // task may be deleted in the callback. | 91 // task may be deleted in the callback. |
85 if (num_displays_configured_ == requests_.size()) | 92 if (num_displays_configured_ == requests_.size()) |
86 callback_.Run(task_status_); | 93 callback_.Run(task_status_); |
87 } | 94 } |
88 | 95 |
89 void ConfigureDisplaysTask::OnConfigured(size_t index, bool success) { | 96 void ConfigureDisplaysTask::OnConfigured(size_t index, bool success) { |
(...skipping 18 matching lines...) Expand all Loading... |
108 } | 115 } |
109 | 116 |
110 num_displays_configured_++; | 117 num_displays_configured_++; |
111 if (!success) | 118 if (!success) |
112 task_status_ = ERROR; | 119 task_status_ = ERROR; |
113 | 120 |
114 Run(); | 121 Run(); |
115 } | 122 } |
116 | 123 |
117 } // namespace ui | 124 } // namespace ui |
OLD | NEW |