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

Unified Diff: components/discardable_memory/service/discardable_shared_memory_manager.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (wip) Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/discardable_memory/service/discardable_shared_memory_manager.cc
diff --git a/components/discardable_memory/service/discardable_shared_memory_manager.cc b/components/discardable_memory/service/discardable_shared_memory_manager.cc
index e2966c798c78bfafbc28f69e0d85095aa9f89582..64d719adcfbefa7a630eb9195c6542f0c7f815ab 100644
--- a/components/discardable_memory/service/discardable_shared_memory_manager.cc
+++ b/components/discardable_memory/service/discardable_shared_memory_manager.cc
@@ -16,6 +16,7 @@
#include "base/memory/discardable_memory.h"
#include "base/memory/memory_coordinator_client_registry.h"
#include "base/memory/ptr_util.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/numerics/safe_math.h"
#include "base/process/memory.h"
#include "base/strings/string_number_conversions.h"
@@ -40,24 +41,8 @@
namespace discardable_memory {
namespace {
-const char kSingleProcess[] = "single-process";
-
const int kInvalidUniqueClientID = -1;
-const uint64_t kBrowserTracingProcessId = std::numeric_limits<uint64_t>::max();
-
-uint64_t ClientProcessUniqueIdToTracingProcessId(int client_id) {
- // TODO(penghuang): Move this function to right place.
- // https://crbug.com/661257
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcess))
- return kBrowserTracingProcessId;
- // The hash value is incremented so that the tracing id is never equal to
- // MemoryDumpManager::kInvalidTracingProcessId.
- return static_cast<uint64_t>(base::Hash(
- reinterpret_cast<const char*>(&client_id), sizeof(client_id))) +
- 1;
-}
-
// mojom::DiscardableSharedMemoryManager implementation. It contains the
// |client_id_| which is not visible to client. We associate allocations with a
// given mojo instance, so if the instance is closed, we can release the
@@ -321,27 +306,25 @@ bool DiscardableSharedMemoryManager::OnMemoryDump(
// corresponding dump for the same segment, this will avoid to
// double-count them in tracing. If, instead, no other process will emit a
// dump with the same guid, the segment will be accounted to the browser.
- const uint64_t client_tracing_id =
- ClientProcessUniqueIdToTracingProcessId(client_id);
- base::trace_event::MemoryAllocatorDumpGuid shared_segment_guid =
- DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing(
- client_tracing_id, segment_id);
- pmd->CreateSharedGlobalAllocatorDump(shared_segment_guid);
- pmd->AddOwnershipEdge(dump->guid(), shared_segment_guid);
+
+ base::SharedMemoryTracker::AddOwnershipEdges(
+ pmd, dump->guid(), segment->memory()->handle(),
+ segment->memory()->mapped_size());
#if defined(COUNT_RESIDENT_BYTES_SUPPORTED)
if (args.level_of_detail ==
base::trace_event::MemoryDumpLevelOfDetail::DETAILED) {
- size_t resident_size =
+ // TODO: Fix this
+ /*size_t resident_size =
base::trace_event::ProcessMemoryDump::CountResidentBytes(
- segment->memory()->memory(), segment->memory()->mapped_size());
+ segment->memory()->memory(), segment->memory()->mapped_size());*/
// This is added to the global dump since it has to be attributed to
// both the allocator dumps involved.
- pmd->GetSharedGlobalAllocatorDump(shared_segment_guid)
+ /*pmd->GetSharedGlobalAllocatorDump(shared_segment_guid)
->AddScalar("resident_size",
hajimehoshi 2017/03/27 10:05:01 I have no idea what is the difference between 'res
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
- static_cast<uint64_t>(resident_size));
+ static_cast<uint64_t>(resident_size));*/
}
#endif // defined(COUNT_RESIDENT_BYTES_SUPPORTED)
}

Powered by Google App Engine
This is Rietveld 408576698