LCOV - code coverage report
Current view: top level - ipc/chromium/src/chrome/common - ipc_channel.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 2 2 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : // Copyright (c) 2012 The Chromium Authors. All rights reserved.
       4             : // Use of this source code is governed by a BSD-style license that can be
       5             : // found in the LICENSE file.
       6             : 
       7             : #include "chrome/common/ipc_channel.h"
       8             : 
       9             : #include <limits>
      10             : 
      11             : #include "base/atomic_sequence_num.h"
      12             : #include "base/process_util.h"
      13             : #include "base/rand_util.h"
      14             : #include "base/string_util.h"
      15             : 
      16             : namespace {
      17             : 
      18             : // Global atomic used to guarantee channel IDs are unique.
      19             : base::StaticAtomicSequenceNumber g_last_id;
      20             : 
      21             : }  // namespace
      22             : 
      23             : namespace IPC {
      24             : 
      25             : // static
      26          15 : std::wstring Channel::GenerateUniqueRandomChannelID() {
      27             :   // Note: the string must start with the current process id, this is how
      28             :   // some child processes determine the pid of the parent.
      29             :   //
      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
      32             :   // component. The strong random component prevents other processes from
      33             :   // hijacking or squatting on predictable channel names.
      34             : 
      35             :   return StringPrintf(L"%d.%u.%d",
      36             :       base::GetCurrentProcId(),
      37             :       g_last_id.GetNext(),
      38          15 :       base::RandInt(0, std::numeric_limits<int32_t>::max()));
      39             : }
      40             : 
      41             : }  // namespace IPC

Generated by: LCOV version 1.13