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

Side by Side Diff: ui/display/manager/chromeos/test/test_native_display_delegate.cc

Issue 2571543002: Fix use after free for cached_displays_. (Closed)
Patch Set: Add invalidate to tests. Created 4 years 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 unified diff | Download patch
OLDNEW
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/manager/chromeos/test/test_native_display_delegate.h" 5 #include "ui/display/manager/chromeos/test/test_native_display_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "ui/display/manager/chromeos/test/action_logger.h" 11 #include "ui/display/manager/chromeos/test/action_logger.h"
12 #include "ui/display/types/display_mode.h" 12 #include "ui/display/types/display_mode.h"
13 #include "ui/display/types/native_display_observer.h"
13 14
14 namespace ui { 15 namespace ui {
15 namespace test { 16 namespace test {
16 17
17 TestNativeDisplayDelegate::TestNativeDisplayDelegate(ActionLogger* log) 18 TestNativeDisplayDelegate::TestNativeDisplayDelegate(ActionLogger* log)
18 : max_configurable_pixels_(0), 19 : max_configurable_pixels_(0),
19 get_hdcp_expectation_(true), 20 get_hdcp_expectation_(true),
20 set_hdcp_expectation_(true), 21 set_hdcp_expectation_(true),
21 hdcp_state_(HDCP_STATE_UNDESIRED), 22 hdcp_state_(HDCP_STATE_UNDESIRED),
22 run_async_(false), 23 run_async_(false),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void TestNativeDisplayDelegate::SetBackgroundColor(uint32_t color_argb) { 56 void TestNativeDisplayDelegate::SetBackgroundColor(uint32_t color_argb) {
56 log_->AppendAction(GetBackgroundAction(color_argb)); 57 log_->AppendAction(GetBackgroundAction(color_argb));
57 } 58 }
58 59
59 void TestNativeDisplayDelegate::ForceDPMSOn() { 60 void TestNativeDisplayDelegate::ForceDPMSOn() {
60 log_->AppendAction(kForceDPMS); 61 log_->AppendAction(kForceDPMS);
61 } 62 }
62 63
63 void TestNativeDisplayDelegate::GetDisplays( 64 void TestNativeDisplayDelegate::GetDisplays(
64 const GetDisplaysCallback& callback) { 65 const GetDisplaysCallback& callback) {
66 // This mimics the behavior of Ozone DRM when new display state arrives.
67 for (NativeDisplayObserver& observer : observers_)
68 observer.OnDisplaySnapshotsInvalidated();
69
65 if (run_async_) { 70 if (run_async_) {
66 base::ThreadTaskRunnerHandle::Get()->PostTask( 71 base::ThreadTaskRunnerHandle::Get()->PostTask(
67 FROM_HERE, base::Bind(callback, outputs_)); 72 FROM_HERE, base::Bind(callback, outputs_));
68 } else { 73 } else {
69 callback.Run(outputs_); 74 callback.Run(outputs_);
70 } 75 }
71 } 76 }
72 77
73 void TestNativeDisplayDelegate::AddMode(const DisplaySnapshot& output, 78 void TestNativeDisplayDelegate::AddMode(const DisplaySnapshot& output,
74 const DisplayMode* mode) { 79 const DisplayMode* mode) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 bool TestNativeDisplayDelegate::SetColorCorrection( 142 bool TestNativeDisplayDelegate::SetColorCorrection(
138 const ui::DisplaySnapshot& output, 143 const ui::DisplaySnapshot& output,
139 const std::vector<GammaRampRGBEntry>& degamma_lut, 144 const std::vector<GammaRampRGBEntry>& degamma_lut,
140 const std::vector<GammaRampRGBEntry>& gamma_lut, 145 const std::vector<GammaRampRGBEntry>& gamma_lut,
141 const std::vector<float>& correction_matrix) { 146 const std::vector<float>& correction_matrix) {
142 log_->AppendAction(SetColorCorrectionAction(output, degamma_lut, gamma_lut, 147 log_->AppendAction(SetColorCorrectionAction(output, degamma_lut, gamma_lut,
143 correction_matrix)); 148 correction_matrix));
144 return true; 149 return true;
145 } 150 }
146 151
147 void TestNativeDisplayDelegate::AddObserver(NativeDisplayObserver* observer) {} 152 void TestNativeDisplayDelegate::AddObserver(NativeDisplayObserver* observer) {
153 observers_.AddObserver(observer);
154 }
148 155
149 void TestNativeDisplayDelegate::RemoveObserver( 156 void TestNativeDisplayDelegate::RemoveObserver(
150 NativeDisplayObserver* observer) {} 157 NativeDisplayObserver* observer) {
158 observers_.RemoveObserver(observer);
159 }
151 160
152 display::FakeDisplayController* 161 display::FakeDisplayController*
153 TestNativeDisplayDelegate::GetFakeDisplayController() { 162 TestNativeDisplayDelegate::GetFakeDisplayController() {
154 return nullptr; 163 return nullptr;
155 } 164 }
156 165
157 } // namespace test 166 } // namespace test
158 } // namespace ui 167 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/manager/chromeos/test/test_native_display_delegate.h ('k') | ui/display/types/native_display_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698