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

Side by Side Diff: cc/surfaces/surface_manager.cc

Issue 590613002: Ensure SurfaceManager is only ever used from one thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « cc/surfaces/surface_manager.h ('k') | no next file » | 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 #include "cc/surfaces/surface_manager.h" 5 #include "cc/surfaces/surface_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 SurfaceManager::SurfaceManager() { 12 SurfaceManager::SurfaceManager() {
13 thread_checker_.DetachFromThread();
13 } 14 }
14 15
15 SurfaceManager::~SurfaceManager() { 16 SurfaceManager::~SurfaceManager() {
17 DCHECK(thread_checker_.CalledOnValidThread());
16 } 18 }
17 19
18 void SurfaceManager::RegisterSurface(Surface* surface) { 20 void SurfaceManager::RegisterSurface(Surface* surface) {
21 DCHECK(thread_checker_.CalledOnValidThread());
19 DCHECK(surface); 22 DCHECK(surface);
20 DCHECK(!surface_map_.count(surface->surface_id())); 23 DCHECK(!surface_map_.count(surface->surface_id()));
21 surface_map_[surface->surface_id()] = surface; 24 surface_map_[surface->surface_id()] = surface;
22 } 25 }
23 26
24 void SurfaceManager::DeregisterSurface(SurfaceId surface_id) { 27 void SurfaceManager::DeregisterSurface(SurfaceId surface_id) {
28 DCHECK(thread_checker_.CalledOnValidThread());
25 SurfaceMap::iterator it = surface_map_.find(surface_id); 29 SurfaceMap::iterator it = surface_map_.find(surface_id);
26 DCHECK(it != surface_map_.end()); 30 DCHECK(it != surface_map_.end());
27 surface_map_.erase(it); 31 surface_map_.erase(it);
28 } 32 }
29 33
30 Surface* SurfaceManager::GetSurfaceForId(SurfaceId surface_id) { 34 Surface* SurfaceManager::GetSurfaceForId(SurfaceId surface_id) {
35 DCHECK(thread_checker_.CalledOnValidThread());
31 SurfaceMap::iterator it = surface_map_.find(surface_id); 36 SurfaceMap::iterator it = surface_map_.find(surface_id);
32 if (it == surface_map_.end()) 37 if (it == surface_map_.end())
33 return NULL; 38 return NULL;
34 return it->second; 39 return it->second;
35 } 40 }
36 41
37 void SurfaceManager::SurfaceModified(SurfaceId surface_id) { 42 void SurfaceManager::SurfaceModified(SurfaceId surface_id) {
43 DCHECK(thread_checker_.CalledOnValidThread());
38 FOR_EACH_OBSERVER( 44 FOR_EACH_OBSERVER(
39 SurfaceDamageObserver, observer_list_, OnSurfaceDamaged(surface_id)); 45 SurfaceDamageObserver, observer_list_, OnSurfaceDamaged(surface_id));
40 } 46 }
41 47
42 } // namespace cc 48 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698