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 "ipc/ipc_channel.h" | 5 #include "ipc/ipc_channel.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <limits> | 9 #include <limits> |
8 | 10 |
9 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
10 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
11 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
12 | 14 |
13 namespace { | 15 namespace { |
14 | 16 |
15 // Global atomic used to guarantee channel IDs are unique. | 17 // Global atomic used to guarantee channel IDs are unique. |
16 base::StaticAtomicSequenceNumber g_last_id; | 18 base::StaticAtomicSequenceNumber g_last_id; |
(...skipping 14 matching lines...) Expand all Loading... |
31 #if defined(OS_NACL_NONSFI) | 33 #if defined(OS_NACL_NONSFI) |
32 // The seccomp sandbox disallows use of getpid(), so we provide a | 34 // The seccomp sandbox disallows use of getpid(), so we provide a |
33 // dummy PID. | 35 // dummy PID. |
34 int process_id = -1; | 36 int process_id = -1; |
35 #else | 37 #else |
36 int process_id = base::GetCurrentProcId(); | 38 int process_id = base::GetCurrentProcId(); |
37 #endif | 39 #endif |
38 return base::StringPrintf("%d.%u.%d", | 40 return base::StringPrintf("%d.%u.%d", |
39 process_id, | 41 process_id, |
40 g_last_id.GetNext(), | 42 g_last_id.GetNext(), |
41 base::RandInt(0, std::numeric_limits<int32>::max())); | 43 base::RandInt(0, std::numeric_limits<int32_t>::max())); |
42 } | 44 } |
43 | 45 |
44 } // namespace IPC | 46 } // namespace IPC |
OLD | NEW |