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

Side by Side Diff: base/memory/shared_memory_handle_posix.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: Implement buckets Created 3 years, 11 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/memory/shared_memory_handle.h"
6
7 #include <sys/stat.h>
8
9 #include "base/strings/stringprintf.h"
10
11 namespace base {
12
13 #if !(defined(OS_MACOSX) && !defined(OS_IOS))
14
15 bool GetIDFromSharedMemoryHandle(const SharedMemoryHandle& handle,
16 SharedMemoryHandleID* id) {
17 // Get file name?
18 struct stat file_stat;
19 if (fstat(static_cast<int>(handle.fd), &file_stat) != 0)
Primiano Tucci (use gerrit) 2017/01/20 16:34:52 I checked the sandbox and fstat seems allowed (goo
hajimehoshi 2017/01/23 11:59:09 Thank you!
20 return false;
21 id->device_id = file_stat.st_dev;
22 id->file_id = file_stat.st_ino;
23 return true;
24 }
25
26 std::string GetSharedMemoryHandleIDString(const SharedMemoryHandleID& id) {
27 return base::StringPrintf("%lld.%lld", static_cast<long long>(id.device_id),
28 static_cast<long long>(id.file_id));
29 }
30
31 #endif
32
33 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698