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

Side by Side Diff: ui/display/win/screen_win.cc

Issue 2926383003: Use ContainsValue() instead of std::find() in ui/aura, ui/display and ui/events (Closed)
Patch Set: Created 3 years, 6 months 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 | « ui/display/manager/managed_display_info.cc ('k') | ui/events/event_source.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/win/screen_win.h" 5 #include "ui/display/win/screen_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellscalingapi.h> 8 #include <shellscalingapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/stl_util.h"
15 #include "base/win/win_util.h" 16 #include "base/win/win_util.h"
16 #include "ui/display/display.h" 17 #include "ui/display/display.h"
17 #include "ui/display/display_layout.h" 18 #include "ui/display/display_layout.h"
18 #include "ui/display/display_layout_builder.h" 19 #include "ui/display/display_layout_builder.h"
19 #include "ui/display/win/display_info.h" 20 #include "ui/display/win/display_info.h"
20 #include "ui/display/win/dpi.h" 21 #include "ui/display/win/dpi.h"
21 #include "ui/display/win/scaling_util.h" 22 #include "ui/display/win/scaling_util.h"
22 #include "ui/display/win/screen_win_display.h" 23 #include "ui/display/win/screen_win_display.h"
23 #include "ui/gfx/geometry/point.h" 24 #include "ui/gfx/geometry/point.h"
24 #include "ui/gfx/geometry/rect.h" 25 #include "ui/gfx/geometry/rect.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 584
584 void ScreenWin::RecordDisplayScaleFactors() const { 585 void ScreenWin::RecordDisplayScaleFactors() const {
585 std::vector<int> unique_scale_factors; 586 std::vector<int> unique_scale_factors;
586 for (const auto& screen_win_display : screen_win_displays_) { 587 for (const auto& screen_win_display : screen_win_displays_) {
587 const float scale_factor = 588 const float scale_factor =
588 screen_win_display.display().device_scale_factor(); 589 screen_win_display.display().device_scale_factor();
589 // Multiply the reported value by 100 to display it as a percentage. Clamp 590 // Multiply the reported value by 100 to display it as a percentage. Clamp
590 // it so that if it's wildly out-of-band we won't send it to the backend. 591 // it so that if it's wildly out-of-band we won't send it to the backend.
591 const int reported_scale = std::min( 592 const int reported_scale = std::min(
592 std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000); 593 std::max(base::checked_cast<int>(scale_factor * 100), 0), 1000);
593 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), 594 if (!base::ContainsValue(unique_scale_factors, reported_scale)) {
594 reported_scale) == unique_scale_factors.end()) {
595 unique_scale_factors.push_back(reported_scale); 595 unique_scale_factors.push_back(reported_scale);
596 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); 596 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale);
597 } 597 }
598 } 598 }
599 } 599 }
600 600
601 } // namespace win 601 } // namespace win
602 } // namespace display 602 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/manager/managed_display_info.cc ('k') | ui/events/event_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698