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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // static | 25 // static |
26 std::string Channel::GenerateUniqueRandomChannelID() { | 26 std::string Channel::GenerateUniqueRandomChannelID() { |
27 // Note: the string must start with the current process id, this is how | 27 // Note: the string must start with the current process id, this is how |
28 // some child processes determine the pid of the parent. | 28 // some child processes determine the pid of the parent. |
29 // | 29 // |
30 // This is composed of a unique incremental identifier, the process ID of | 30 // This is composed of a unique incremental identifier, the process ID of |
31 // the creator, an identifier for the child instance, and a strong random | 31 // the creator, an identifier for the child instance, and a strong random |
32 // component. The strong random component prevents other processes from | 32 // component. The strong random component prevents other processes from |
33 // hijacking or squatting on predictable channel names. | 33 // hijacking or squatting on predictable channel names. |
34 | 34 |
35 #if !defined(OS_NACL) | |
36 int process_id = base::GetCurrentProcId(); | 35 int process_id = base::GetCurrentProcId(); |
37 return base::StringPrintf("%d.%u.%d", | 36 return base::StringPrintf("%d.%u.%d", |
38 process_id, | 37 process_id, |
39 g_last_id.GetNext(), | 38 g_last_id.GetNext(), |
40 base::RandInt(0, std::numeric_limits<int32>::max())); | 39 base::RandInt(0, std::numeric_limits<int32>::max())); |
41 #else | |
42 return std::string(); | |
43 #endif | |
44 } | 40 } |
45 | 41 |
46 } // namespace IPC | 42 } // namespace IPC |
47 | 43 |
OLD | NEW |