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

Side by Side Diff: chrome/common/child_process_info.cc

Issue 339059: Add compiler-specific "examine printf format" attributes to printfs. (Closed)
Patch Set: cleanups Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/common/child_process_info.h" 5 #include "chrome/common/child_process_info.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 id_ = id; 99 id_ = id;
100 } 100 }
101 101
102 std::string ChildProcessInfo::GenerateRandomChannelID(void* instance) { 102 std::string ChildProcessInfo::GenerateRandomChannelID(void* instance) {
103 // Note: the string must start with the current process id, this is how 103 // Note: the string must start with the current process id, this is how
104 // child processes determine the pid of the parent. 104 // child processes determine the pid of the parent.
105 // Build the channel ID. This is composed of a unique identifier for the 105 // Build the channel ID. This is composed of a unique identifier for the
106 // parent browser process, an identifier for the child instance, and a random 106 // parent browser process, an identifier for the child instance, and a random
107 // component. We use a random component so that a hacked child process can't 107 // component. We use a random component so that a hacked child process can't
108 // cause denial of service by causing future named pipe creation to fail. 108 // cause denial of service by causing future named pipe creation to fail.
109 return StringPrintf("%d.%x.%d", 109 return StringPrintf("%d.%p.%d",
110 base::GetCurrentProcId(), instance, 110 base::GetCurrentProcId(), instance,
111 base::RandInt(0, std::numeric_limits<int>::max())); 111 base::RandInt(0, std::numeric_limits<int>::max()));
112 } 112 }
113 113
114 // static 114 // static
115 int ChildProcessInfo::GenerateChildProcessUniqueId() { 115 int ChildProcessInfo::GenerateChildProcessUniqueId() {
116 // This function must be threadsafe. 116 // This function must be threadsafe.
117 static base::subtle::Atomic32 last_unique_child_id = 0; 117 static base::subtle::Atomic32 last_unique_child_id = 0;
118 return base::subtle::NoBarrier_AtomicIncrement(&last_unique_child_id, 1); 118 return base::subtle::NoBarrier_AtomicIncrement(&last_unique_child_id, 1);
119 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698