blob: 522c1dde9191c5c0eeec2ddf3cbbb42cb72d2231 [file] [log] [blame]
Elly Jonesa44d22d2012-01-05 18:05:56 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Elly Jonese7cb5b32011-12-01 14:18:32 -05002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alex Vakulenko262be3f2014-07-30 15:25:50 -07005#ifndef DEBUGD_SRC_PROCESS_WITH_ID_H_
6#define DEBUGD_SRC_PROCESS_WITH_ID_H_
Ben Chana0011d82014-05-13 00:19:29 -07007
8#include <string>
Elly Jonese7cb5b32011-12-01 14:18:32 -05009
Alex Vakulenko262be3f2014-07-30 15:25:50 -070010#include "debugd/src/sandboxed_process.h"
Elly Jonese7cb5b32011-12-01 14:18:32 -050011
12namespace debugd {
13
14// @brief Represents a process with an immutable ID.
15//
16// The ID is random, unguessable, and may be given to other processes. It is a
17// null-terminated ASCII string.
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050018class ProcessWithId : public SandboxedProcess {
Elly Jonese7cb5b32011-12-01 14:18:32 -050019 public:
Ben Chan78f89532014-08-29 09:35:09 -070020 ProcessWithId() = default;
21 ~ProcessWithId() override = default;
Ben Chan4b110122014-08-29 08:22:59 -070022
23 bool Init() override;
24
Ben Chana0011d82014-05-13 00:19:29 -070025 const std::string& id() const { return id_; }
26
Elly Jonese7cb5b32011-12-01 14:18:32 -050027 private:
Ben Chan92f092e2017-02-15 11:55:47 -080028 void GenerateId();
Ben Chan4b110122014-08-29 08:22:59 -070029
Elly Jonese7cb5b32011-12-01 14:18:32 -050030 std::string id_;
31};
32
Ben Chana0011d82014-05-13 00:19:29 -070033} // namespace debugd
Elly Jonese7cb5b32011-12-01 14:18:32 -050034
Alex Vakulenko262be3f2014-07-30 15:25:50 -070035#endif // DEBUGD_SRC_PROCESS_WITH_ID_H_