OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef UI_DISPLAY_DISPLAY_LIST_H_ | 5 #ifndef UI_DISPLAY_DISPLAY_LIST_H_ |
6 #define UI_DISPLAY_DISPLAY_LIST_H_ | 6 #define UI_DISPLAY_DISPLAY_LIST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 Displays::const_iterator FindDisplayById(int64_t id) const; | 58 Displays::const_iterator FindDisplayById(int64_t id) const; |
59 Displays::iterator FindDisplayById(int64_t id); | 59 Displays::iterator FindDisplayById(int64_t id); |
60 | 60 |
61 Displays::const_iterator GetPrimaryDisplayIterator() const; | 61 Displays::const_iterator GetPrimaryDisplayIterator() const; |
62 | 62 |
63 // Internally increments a counter that while non-zero results in observers | 63 // Internally increments a counter that while non-zero results in observers |
64 // not being called for any changes to the displays. It is assumed once | 64 // not being called for any changes to the displays. It is assumed once |
65 // callers release the last lock they call the observers appropriately. | 65 // callers release the last lock they call the observers appropriately. |
66 std::unique_ptr<DisplayListObserverLock> SuspendObserverUpdates(); | 66 std::unique_ptr<DisplayListObserverLock> SuspendObserverUpdates(); |
67 | 67 |
68 // Updates the cached id based on display.id() as well as whether the Display | 68 // Updates the cached display based on display.id(). |
69 // is the primary display. | 69 void UpdateDisplay(const display::Display& display); |
| 70 |
| 71 // Updates the cached display based on display.id(). Also updates the primary |
| 72 // display if |type| indicates |display| is the primary display. |
70 void UpdateDisplay(const display::Display& display, Type type); | 73 void UpdateDisplay(const display::Display& display, Type type); |
71 | 74 |
72 // Adds a new Display. | 75 // Adds a new Display. |
73 void AddDisplay(const display::Display& display, Type type); | 76 void AddDisplay(const display::Display& display, Type type); |
74 | 77 |
75 // Removes the Display with the specified id. | 78 // Removes the Display with the specified id. |
76 void RemoveDisplay(int64_t id); | 79 void RemoveDisplay(int64_t id); |
77 | 80 |
78 base::ObserverList<display::DisplayObserver>* observers() { | 81 base::ObserverList<display::DisplayObserver>* observers() { |
79 return &observers_; | 82 return &observers_; |
80 } | 83 } |
81 | 84 |
82 private: | 85 private: |
83 friend class DisplayListObserverLock; | 86 friend class DisplayListObserverLock; |
84 | 87 |
85 bool should_notify_observers() const { | 88 bool should_notify_observers() const { |
86 return observer_suspend_lock_count_ == 0; | 89 return observer_suspend_lock_count_ == 0; |
87 } | 90 } |
88 void IncrementObserverSuspendLockCount(); | 91 void IncrementObserverSuspendLockCount(); |
89 void DecrementObserverSuspendLockCount(); | 92 void DecrementObserverSuspendLockCount(); |
90 | 93 |
| 94 Type GetTypeByDisplayId(int64_t display_id) const; |
| 95 |
91 std::vector<display::Display> displays_; | 96 std::vector<display::Display> displays_; |
92 int primary_display_index_ = -1; | 97 int primary_display_index_ = -1; |
93 base::ObserverList<display::DisplayObserver> observers_; | 98 base::ObserverList<display::DisplayObserver> observers_; |
94 | 99 |
95 int observer_suspend_lock_count_ = 0; | 100 int observer_suspend_lock_count_ = 0; |
96 | 101 |
97 DISALLOW_COPY_AND_ASSIGN(DisplayList); | 102 DISALLOW_COPY_AND_ASSIGN(DisplayList); |
98 }; | 103 }; |
99 | 104 |
100 } // namespace display | 105 } // namespace display |
101 | 106 |
102 #endif // UI_DISPLAY_DISPLAY_LIST_H_ | 107 #endif // UI_DISPLAY_DISPLAY_LIST_H_ |
OLD | NEW |