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

Side by Side Diff: ipc/ipc_channel.cc

Issue 553283002: IPC::ChannelMojo: Introduce IPC::MojoBootstrap for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing windows build error 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
OLDNEW
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/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 12
13 #if !defined(OS_NACL) 13 #if !defined(OS_NACL)
14 namespace { 14 namespace {
15 15
16 // Global atomic used to guarantee channel IDs are unique. 16 // Global atomic used to guarantee channel IDs are unique.
17 base::StaticAtomicSequenceNumber g_last_id; 17 base::StaticAtomicSequenceNumber g_last_id;
18 18
19 } // namespace 19 } // namespace
20 #endif 20 #endif
21 21
22 namespace IPC { 22 namespace IPC {
23 23
24 void Channel::OnClientLaunched(base::ProcessHandle handle) {
25 }
26
27 #if !defined(OS_NACL)
24 // static 28 // static
25 std::string Channel::GenerateUniqueRandomChannelID() { 29 std::string Channel::GenerateUniqueRandomChannelID() {
26 // Note: the string must start with the current process id, this is how 30 // Note: the string must start with the current process id, this is how
27 // some child processes determine the pid of the parent. 31 // some child processes determine the pid of the parent.
28 // 32 //
29 // This is composed of a unique incremental identifier, the process ID of 33 // This is composed of a unique incremental identifier, the process ID of
30 // the creator, an identifier for the child instance, and a strong random 34 // the creator, an identifier for the child instance, and a strong random
31 // component. The strong random component prevents other processes from 35 // component. The strong random component prevents other processes from
32 // hijacking or squatting on predictable channel names. 36 // hijacking or squatting on predictable channel names.
33 37
34 int process_id = base::GetCurrentProcId(); 38 int process_id = base::GetCurrentProcId();
35 return base::StringPrintf("%d.%u.%d", 39 return base::StringPrintf("%d.%u.%d",
36 process_id, 40 process_id,
37 g_last_id.GetNext(), 41 g_last_id.GetNext(),
38 base::RandInt(0, std::numeric_limits<int32>::max())); 42 base::RandInt(0, std::numeric_limits<int32>::max()));
39 } 43 }
44 #endif
40 45
41 } // namespace IPC 46 } // namespace IPC
42 47
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698