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

Side by Side Diff: ui/display/manager/chromeos/display_change_observer.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
« no previous file with comments | « no previous file | ui/display/manager/chromeos/display_configurator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/display_change_observer.h" 5 #include "ui/display/manager/chromeos/display_change_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 const ui::DisplayConfigurator::DisplayStateList& displays, 281 const ui::DisplayConfigurator::DisplayStateList& displays,
282 ui::MultipleDisplayState failed_new_state) { 282 ui::MultipleDisplayState failed_new_state) {
283 // If display configuration failed during startup, simply update the display 283 // If display configuration failed during startup, simply update the display
284 // manager with detected displays. If no display is detected, it will 284 // manager with detected displays. If no display is detected, it will
285 // create a pseudo display. 285 // create a pseudo display.
286 if (display_manager_->GetNumDisplays() == 0) 286 if (display_manager_->GetNumDisplays() == 0)
287 OnDisplayModeChanged(displays); 287 OnDisplayModeChanged(displays);
288 } 288 }
289 289
290 void DisplayChangeObserver::OnTouchscreenDeviceConfigurationChanged() { 290 void DisplayChangeObserver::OnTouchscreenDeviceConfigurationChanged() {
291 OnDisplayModeChanged(display_configurator_->cached_displays()); 291 // If there are no cached display snapshots, either there are no attached
292 // displays or the cached snapshots have been invalidated. For the first case
293 // there aren't any touchscreens to associate. For the second case, the
294 // displays and touch input-devices will get associated when display
295 // configuration finishes.
296 const auto& cached_displays = display_configurator_->cached_displays();
297 if (!cached_displays.empty())
298 OnDisplayModeChanged(cached_displays);
299 else
300 VLOG(1) << "Not updating touchscreen associations";
292 } 301 }
293 302
294 // static 303 // static
295 float DisplayChangeObserver::FindDeviceScaleFactor(float dpi) { 304 float DisplayChangeObserver::FindDeviceScaleFactor(float dpi) {
296 for (size_t i = 0; i < arraysize(kThresholdTable); ++i) { 305 for (size_t i = 0; i < arraysize(kThresholdTable); ++i) {
297 if (dpi > kThresholdTable[i].dpi) 306 if (dpi > kThresholdTable[i].dpi)
298 return kThresholdTable[i].device_scale_factor; 307 return kThresholdTable[i].device_scale_factor;
299 } 308 }
300 return 1.0f; 309 return 1.0f;
301 } 310 }
302 311
303 } // namespace display 312 } // namespace display
OLDNEW
« no previous file with comments | « no previous file | ui/display/manager/chromeos/display_configurator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698