forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tracing] Add SkResourceCache statistics to chrome://tracing (chrome …
…side) This CL adds the statistics of SkResourceCache to tracing. See crrev.com/1313793004 for the skia side changes. BUG=503168 Review URL: https://codereview.chromium.org/1319473003 Cr-Commit-Position: refs/heads/master@{#347207}
- Loading branch information
1 parent
cbf0dc0
commit 7040503
Showing
8 changed files
with
181 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2015 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 "skia/ext/SkTraceMemoryDump_chrome.h" | ||
|
||
#include "base/trace_event/memory_allocator_dump.h" | ||
#include "base/trace_event/memory_dump_manager.h" | ||
#include "base/trace_event/process_memory_dump.h" | ||
#include "skia/ext/SkDiscardableMemory_chrome.h" | ||
|
||
namespace skia { | ||
|
||
namespace { | ||
const char kMallocBackingType[] = "malloc"; | ||
} | ||
|
||
SkTraceMemoryDump_Chrome::SkTraceMemoryDump_Chrome( | ||
base::trace_event::ProcessMemoryDump* process_memory_dump) | ||
: SkTraceMemoryDump_Chrome("", process_memory_dump) {} | ||
|
||
SkTraceMemoryDump_Chrome::SkTraceMemoryDump_Chrome( | ||
const char* dump_name_prefix, | ||
base::trace_event::ProcessMemoryDump* process_memory_dump) | ||
: dump_name_prefix_(dump_name_prefix), | ||
process_memory_dump_(process_memory_dump) {} | ||
|
||
SkTraceMemoryDump_Chrome::~SkTraceMemoryDump_Chrome() {} | ||
|
||
void SkTraceMemoryDump_Chrome::dumpNumericValue(const char* dumpName, | ||
const char* valueName, | ||
const char* units, | ||
uint64_t value) { | ||
auto dump = GetOrCreateAllocatorDump(dumpName); | ||
dump->AddScalar(valueName, units, value); | ||
} | ||
|
||
void SkTraceMemoryDump_Chrome::setMemoryBacking(const char* dumpName, | ||
const char* backingType, | ||
const char* backingObjectId) { | ||
if (strcmp(backingType, kMallocBackingType) == 0) { | ||
auto dump = GetOrCreateAllocatorDump(dumpName); | ||
const char* system_allocator_name = | ||
base::trace_event::MemoryDumpManager::GetInstance() | ||
->system_allocator_pool_name(); | ||
if (system_allocator_name) { | ||
process_memory_dump_->AddSuballocation(dump->guid(), | ||
system_allocator_name); | ||
} | ||
} else { | ||
NOTREACHED(); | ||
} | ||
} | ||
|
||
void SkTraceMemoryDump_Chrome::setDiscardableMemoryBacking( | ||
const char* dumpName, | ||
const SkDiscardableMemory& discardableMemoryObject) { | ||
std::string name = dump_name_prefix_ + dumpName; | ||
DCHECK(!process_memory_dump_->GetAllocatorDump(name)); | ||
const SkDiscardableMemoryChrome& discardable_memory_obj = | ||
static_cast<const SkDiscardableMemoryChrome&>(discardableMemoryObject); | ||
auto dump = discardable_memory_obj.CreateMemoryAllocatorDump( | ||
name.c_str(), process_memory_dump_); | ||
DCHECK(dump); | ||
} | ||
|
||
base::trace_event::MemoryAllocatorDump* | ||
SkTraceMemoryDump_Chrome::GetOrCreateAllocatorDump(const char* dumpName) { | ||
std::string name = dump_name_prefix_ + dumpName; | ||
auto dump = process_memory_dump_->GetAllocatorDump(name); | ||
if (!dump) | ||
dump = process_memory_dump_->CreateAllocatorDump(name); | ||
return dump; | ||
} | ||
|
||
} // namespace skia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2015 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. | ||
|
||
#ifndef SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ | ||
#define SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ | ||
|
||
#include <string> | ||
|
||
#include "base/macros.h" | ||
#include "third_party/skia/include/core/SkTraceMemoryDump.h" | ||
|
||
namespace base { | ||
namespace trace_event { | ||
class MemoryAllocatorDump; | ||
class ProcessMemoryDump; | ||
} | ||
} | ||
|
||
namespace skia { | ||
|
||
class SkTraceMemoryDump_Chrome : public SkTraceMemoryDump { | ||
public: | ||
// This should never outlive the OnMemoryDump call since the | ||
// ProcessMemoryDump is valid only in that timeframe. Optional | ||
// |dump_name_prefix| argument specifies the prefix appended to the dump | ||
// name skia provides. By defualt it is taken as empty string. | ||
SkTraceMemoryDump_Chrome( | ||
base::trace_event::ProcessMemoryDump* process_memory_dump); | ||
|
||
SkTraceMemoryDump_Chrome( | ||
const char* dump_name_prefix, | ||
base::trace_event::ProcessMemoryDump* process_memory_dump); | ||
|
||
~SkTraceMemoryDump_Chrome() override; | ||
|
||
// SkTraceMemoryDump implementation: | ||
void dumpNumericValue(const char* dumpName, | ||
const char* valueName, | ||
const char* units, | ||
uint64_t value) override; | ||
void setMemoryBacking(const char* dumpName, | ||
const char* backingType, | ||
const char* backingObjectId) override; | ||
void setDiscardableMemoryBacking( | ||
const char* dumpName, | ||
const SkDiscardableMemory& discardableMemoryObject) override; | ||
|
||
protected: | ||
base::trace_event::ProcessMemoryDump* process_memory_dump() { | ||
return process_memory_dump_; | ||
} | ||
|
||
private: | ||
base::trace_event::ProcessMemoryDump* process_memory_dump_; | ||
|
||
std::string dump_name_prefix_; | ||
|
||
// Helper to create allocator dumps. | ||
base::trace_event::MemoryAllocatorDump* GetOrCreateAllocatorDump( | ||
const char* dumpName); | ||
|
||
DISALLOW_COPY_AND_ASSIGN(SkTraceMemoryDump_Chrome); | ||
}; | ||
|
||
} // namespace skia | ||
|
||
#endif // SKIA_EXT_SK_TRACE_MEMORY_DUMP_CHROME_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters