| Index: base/memory/shared_memory_handle_posix.cc
|
| diff --git a/base/memory/shared_memory_handle_posix.cc b/base/memory/shared_memory_handle_posix.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e4e32107db3ef3ec2310a18ea8de6d08a4a483f2
|
| --- /dev/null
|
| +++ b/base/memory/shared_memory_handle_posix.cc
|
| @@ -0,0 +1,33 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/memory/shared_memory_handle.h"
|
| +
|
| +#include <sys/stat.h>
|
| +
|
| +#include "base/strings/stringprintf.h"
|
| +
|
| +namespace base {
|
| +
|
| +#if !(defined(OS_MACOSX) && !defined(OS_IOS))
|
| +
|
| +bool GetIDFromSharedMemoryHandle(const SharedMemoryHandle& handle,
|
| + SharedMemoryHandleID* id) {
|
| + // Get file name?
|
| + struct stat file_stat;
|
| + if (fstat(static_cast<int>(handle.fd), &file_stat) != 0)
|
| + return false;
|
| + id->device_id = file_stat.st_dev;
|
| + id->file_id = file_stat.st_ino;
|
| + return true;
|
| +}
|
| +
|
| +std::string GetSharedMemoryHandleIDString(const SharedMemoryHandleID& id) {
|
| + return base::StringPrintf("%lld.%lld", static_cast<long long>(id.device_id),
|
| + static_cast<long long>(id.file_id));
|
| +}
|
| +
|
| +#endif
|
| +
|
| +} // namespace base
|
|
|