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

Side by Side Diff: ui/display/manager/chromeos/display_configurator.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/display_configurator.h" 5 #include "ui/display/manager/chromeos/display_configurator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 517
518 void DisplayConfigurator::Init( 518 void DisplayConfigurator::Init(
519 std::unique_ptr<NativeDisplayDelegate> display_delegate, 519 std::unique_ptr<NativeDisplayDelegate> display_delegate,
520 bool is_panel_fitting_enabled) { 520 bool is_panel_fitting_enabled) {
521 is_panel_fitting_enabled_ = is_panel_fitting_enabled; 521 is_panel_fitting_enabled_ = is_panel_fitting_enabled;
522 if (!configure_display_ || display_externally_controlled_) 522 if (!configure_display_ || display_externally_controlled_)
523 return; 523 return;
524 524
525 // If the delegate is already initialized don't update it (For example, tests 525 // If the delegate is already initialized don't update it (For example, tests
526 // set their own delegates). 526 // set their own delegates).
527 if (!native_display_delegate_) { 527 if (!native_display_delegate_)
528 native_display_delegate_ = std::move(display_delegate); 528 native_display_delegate_ = std::move(display_delegate);
529 native_display_delegate_->AddObserver(this); 529
530 } 530 native_display_delegate_->AddObserver(this);
531 } 531 }
532 532
533 void DisplayConfigurator::TakeControl(const DisplayControlCallback& callback) { 533 void DisplayConfigurator::TakeControl(const DisplayControlCallback& callback) {
534 if (display_control_changing_) { 534 if (display_control_changing_) {
535 callback.Run(false); 535 callback.Run(false);
536 return; 536 return;
537 } 537 }
538 538
539 if (!display_externally_controlled_) { 539 if (!display_externally_controlled_) {
540 callback.Run(true); 540 callback.Run(true);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 return; 940 return;
941 } 941 }
942 942
943 // Configure displays with |kConfigureDelayMs| delay, 943 // Configure displays with |kConfigureDelayMs| delay,
944 // so that time-consuming ConfigureDisplays() won't be called multiple times. 944 // so that time-consuming ConfigureDisplays() won't be called multiple times.
945 configure_timer_.Start(FROM_HERE, 945 configure_timer_.Start(FROM_HERE,
946 base::TimeDelta::FromMilliseconds(kConfigureDelayMs), 946 base::TimeDelta::FromMilliseconds(kConfigureDelayMs),
947 this, &DisplayConfigurator::ConfigureDisplays); 947 this, &DisplayConfigurator::ConfigureDisplays);
948 } 948 }
949 949
950 void DisplayConfigurator::OnDisplaySnapshotsInvalidated() {
951 VLOG(1) << "Display snapshots invalidated.";
952 cached_displays_.clear();
953 }
954
950 void DisplayConfigurator::AddObserver(Observer* observer) { 955 void DisplayConfigurator::AddObserver(Observer* observer) {
951 observers_.AddObserver(observer); 956 observers_.AddObserver(observer);
952 } 957 }
953 958
954 void DisplayConfigurator::RemoveObserver(Observer* observer) { 959 void DisplayConfigurator::RemoveObserver(Observer* observer) {
955 observers_.RemoveObserver(observer); 960 observers_.RemoveObserver(observer);
956 } 961 }
957 962
958 void DisplayConfigurator::SuspendDisplays( 963 void DisplayConfigurator::SuspendDisplays(
959 const ConfigurationCallback& callback) { 964 const ConfigurationCallback& callback) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 last_virtual_display_id_ = max_display_id & 0xff; 1192 last_virtual_display_id_ = max_display_id & 0xff;
1188 1193
1189 return true; 1194 return true;
1190 } 1195 }
1191 1196
1192 bool DisplayConfigurator::IsDisplayOn() const { 1197 bool DisplayConfigurator::IsDisplayOn() const {
1193 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF; 1198 return current_power_state_ != chromeos::DISPLAY_POWER_ALL_OFF;
1194 } 1199 }
1195 1200
1196 } // namespace ui 1201 } // namespace ui
OLDNEW
« no previous file with comments | « ui/display/manager/chromeos/display_configurator.h ('k') | ui/display/manager/chromeos/test/test_native_display_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698