| OLD | NEW |
| 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_id_allocator.h" | 5 #include "cc/surfaces/surface_id_allocator.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 SurfaceIdAllocator::SurfaceIdAllocator() : next_id_(1u) {} | 13 SurfaceIdAllocator::SurfaceIdAllocator() : next_id_(1u) {} |
| 14 | 14 |
| 15 SurfaceIdAllocator::~SurfaceIdAllocator() { | 15 SurfaceIdAllocator::~SurfaceIdAllocator() { |
| 16 } | 16 } |
| 17 | 17 |
| 18 LocalFrameId SurfaceIdAllocator::GenerateId() { | 18 LocalFrameId SurfaceIdAllocator::GenerateId() { |
| 19 uint64_t nonce = base::RandUint64(); | 19 uint64_t nonce = base::RandUint64(); |
| 20 // Since 0 nonce are treated as uninitialized and thus invalid, we need to |
| 21 // keep generating until there is a non-zero nonce |
| 22 while (nonce == 0) |
| 23 nonce = base::RandUint64(); |
| 20 LocalFrameId id(next_id_, nonce); | 24 LocalFrameId id(next_id_, nonce); |
| 21 next_id_++; | 25 next_id_++; |
| 22 return id; | 26 return id; |
| 23 } | 27 } |
| 24 | 28 |
| 25 } // namespace cc | 29 } // namespace cc |
| OLD | NEW |