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

Unified Diff: mojo/public/cpp/system/watcher.cc

Issue 2623263005: Tag some of Mojo heap allocations for the heap profiler. (Closed)
Patch Set: Synced 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/system/watcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/watcher.cc
diff --git a/mojo/public/cpp/system/watcher.cc b/mojo/public/cpp/system/watcher.cc
index fc03c5a0a0e8b1f4e41c01b29705d743e051d34c..55dcf4023e2b719ea7e9fe28451c5280f05e9654 100644
--- a/mojo/public/cpp/system/watcher.cc
+++ b/mojo/public/cpp/system/watcher.cc
@@ -7,14 +7,17 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/macros.h"
+#include "base/trace_event/heap_profiler.h"
#include "mojo/public/c/system/functions.h"
namespace mojo {
-Watcher::Watcher(scoped_refptr<base::SingleThreadTaskRunner> runner)
+Watcher::Watcher(const tracked_objects::Location& from_here,
+ scoped_refptr<base::SingleThreadTaskRunner> runner)
: task_runner_(std::move(runner)),
is_default_task_runner_(task_runner_ ==
base::ThreadTaskRunnerHandle::Get()),
+ heap_profiler_tag_(from_here.file_name()),
weak_factory_(this) {
DCHECK(task_runner_->BelongsToCurrentThread());
weak_self_ = weak_factory_.GetWeakPtr();
@@ -79,8 +82,10 @@ void Watcher::OnHandleReady(MojoResult result) {
}
// NOTE: It's legal for |callback| to delete |this|.
- if (!callback.is_null())
+ if (!callback.is_null()) {
+ TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION event(heap_profiler_tag_);
callback.Run(result);
+ }
}
// static
@@ -94,6 +99,7 @@ void Watcher::CallOnHandleReady(uintptr_t context,
// TODO: Maybe we should also expose |signals_state| through the Watcher API.
// Current HandleWatcher users have no need for it, so it's omitted here.
Watcher* watcher = reinterpret_cast<Watcher*>(context);
+
if ((flags & MOJO_WATCH_NOTIFICATION_FLAG_FROM_SYSTEM) &&
watcher->task_runner_->RunsTasksOnCurrentThread() &&
watcher->is_default_task_runner_) {
« no previous file with comments | « mojo/public/cpp/system/watcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698