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

Side by Side Diff: components/mus/public/cpp/lib/window_tree_client_impl.h

Issue 1982333002: Candidate fix for observe-window-after-free error in WindowTreeClientImpl::LocalSetCapture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Guard observer's AddObserver invocation Created 4 years, 7 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 | « no previous file | components/mus/public/cpp/lib/window_tree_client_impl.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 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 #ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_
6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ 6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // the last step of ~Window). 126 // the last step of ~Window).
127 void OnWindowDestroyed(Window* window); 127 void OnWindowDestroyed(Window* window);
128 128
129 Window* GetWindowByServerId(Id id); 129 Window* GetWindowByServerId(Id id);
130 130
131 // WindowTreeConnection: 131 // WindowTreeConnection:
132 Window* GetCaptureWindow() override; 132 Window* GetCaptureWindow() override;
133 133
134 private: 134 private:
135 friend class WindowTreeClientImplPrivate; 135 friend class WindowTreeClientImplPrivate;
136 class MusWindowObserver;
136 137
137 enum class NewWindowType { 138 enum class NewWindowType {
138 CHILD, 139 CHILD,
139 TOP_LEVEL, 140 TOP_LEVEL,
140 }; 141 };
141 142
142 using IdToWindowMap = std::map<Id, Window*>; 143 using IdToWindowMap = std::map<Id, Window*>;
143 144
144 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. 145 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption.
145 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; 146 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>;
146 147
147 // Returns the oldest InFlightChange that matches |change|. 148 // Returns the oldest InFlightChange that matches |change|.
148 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change); 149 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change);
149 150
151 void SetCaptureWindow(Window* window);
152
150 // See InFlightChange for details on how InFlightChanges are used. 153 // See InFlightChange for details on how InFlightChanges are used.
151 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change); 154 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change);
152 155
153 // Returns true if there is an InFlightChange that matches |change|. If there 156 // Returns true if there is an InFlightChange that matches |change|. If there
154 // is an existing change SetRevertValueFrom() is invoked on it. Returns false 157 // is an existing change SetRevertValueFrom() is invoked on it. Returns false
155 // if there is no InFlightChange matching |change|. 158 // if there is no InFlightChange matching |change|.
156 // See InFlightChange for details on how InFlightChanges are used. 159 // See InFlightChange for details on how InFlightChanges are used.
157 bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change); 160 bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change);
158 161
159 Window* NewWindowImpl(NewWindowType type, 162 Window* NewWindowImpl(NewWindowType type,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 InFlightMap in_flight_map_; 284 InFlightMap in_flight_map_;
282 285
283 WindowTreeDelegate* delegate_; 286 WindowTreeDelegate* delegate_;
284 287
285 WindowManagerDelegate* window_manager_delegate_; 288 WindowManagerDelegate* window_manager_delegate_;
286 289
287 std::set<Window*> roots_; 290 std::set<Window*> roots_;
288 291
289 IdToWindowMap windows_; 292 IdToWindowMap windows_;
290 293
291 Window* capture_window_; 294 std::unique_ptr<MusWindowObserver> capture_window_observer_;
292 295
293 Window* focused_window_; 296 Window* focused_window_;
294 297
295 mojo::Binding<WindowTreeClient> binding_; 298 mojo::Binding<WindowTreeClient> binding_;
296 mojom::WindowTreePtr tree_ptr_; 299 mojom::WindowTreePtr tree_ptr_;
297 // Typically this is the value contained in |tree_ptr_|, but tests may 300 // Typically this is the value contained in |tree_ptr_|, but tests may
298 // directly set this. 301 // directly set this.
299 mojom::WindowTree* tree_; 302 mojom::WindowTree* tree_;
300 303
301 bool delete_on_no_roots_; 304 bool delete_on_no_roots_;
(...skipping 20 matching lines...) Expand all
322 uint32_t event_observer_id_ = 0u; 325 uint32_t event_observer_id_ = 0u;
323 326
324 base::WeakPtrFactory<WindowTreeClientImpl> weak_factory_; 327 base::WeakPtrFactory<WindowTreeClientImpl> weak_factory_;
325 328
326 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl); 329 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl);
327 }; 330 };
328 331
329 } // namespace mus 332 } // namespace mus
330 333
331 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_ 334 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_WINDOW_TREE_CLIENT_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | components/mus/public/cpp/lib/window_tree_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698