| OLD | NEW |
| 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 "content/common/gpu/sync_point_manager.h" | 5 #include "content/common/gpu/sync_point_manager.h" |
| 6 | 6 |
| 7 #include <climits> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/rand_util.h" |
| 8 | 11 |
| 9 namespace content { | 12 namespace content { |
| 10 | 13 |
| 14 static const int kMaxSyncBase = INT_MAX; |
| 15 |
| 11 SyncPointManager::SyncPointManager() | 16 SyncPointManager::SyncPointManager() |
| 12 : next_sync_point_(1) { | 17 : next_sync_point_(base::RandInt(1, kMaxSyncBase)) { |
| 18 // To reduce the risk that a sync point created in a previous GPU process |
| 19 // will be in flight in the next GPU process, randomize the starting sync |
| 20 // point number. http://crbug.com/373452 |
| 13 } | 21 } |
| 14 | 22 |
| 15 SyncPointManager::~SyncPointManager() { | 23 SyncPointManager::~SyncPointManager() { |
| 16 } | 24 } |
| 17 | 25 |
| 18 uint32 SyncPointManager::GenerateSyncPoint() { | 26 uint32 SyncPointManager::GenerateSyncPoint() { |
| 19 base::AutoLock lock(lock_); | 27 base::AutoLock lock(lock_); |
| 20 uint32 sync_point = next_sync_point_++; | 28 uint32 sync_point = next_sync_point_++; |
| 21 | 29 |
| 22 // Note: wrapping would take days for a buggy/compromized renderer that would | 30 // Note: wrapping would take days for a buggy/compromized renderer that would |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 bool SyncPointManager::IsSyncPointRetired(uint32 sync_point) { | 68 bool SyncPointManager::IsSyncPointRetired(uint32 sync_point) { |
| 61 DCHECK(thread_checker_.CalledOnValidThread()); | 69 DCHECK(thread_checker_.CalledOnValidThread()); |
| 62 { | 70 { |
| 63 base::AutoLock lock(lock_); | 71 base::AutoLock lock(lock_); |
| 64 SyncPointMap::iterator it = sync_point_map_.find(sync_point); | 72 SyncPointMap::iterator it = sync_point_map_.find(sync_point); |
| 65 return it == sync_point_map_.end(); | 73 return it == sync_point_map_.end(); |
| 66 } | 74 } |
| 67 } | 75 } |
| 68 | 76 |
| 69 } // namespace content | 77 } // namespace content |
| OLD | NEW |