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

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

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/tests/watcher_unittest.cc ('k') | mojo/public/cpp/system/watcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/watcher.h
diff --git a/mojo/public/cpp/system/watcher.h b/mojo/public/cpp/system/watcher.h
index 815b73b3b50b1d7dc71bbb465587862a2aeb2301..236788b1c853139367df8b0a56b44859064219ca 100644
--- a/mojo/public/cpp/system/watcher.h
+++ b/mojo/public/cpp/system/watcher.h
@@ -36,8 +36,9 @@ class MOJO_CPP_SYSTEM_EXPORT Watcher {
// been cancelled implicitly.
using ReadyCallback = base::Callback<void(MojoResult result)>;
- explicit Watcher(scoped_refptr<base::SingleThreadTaskRunner> runner =
- base::ThreadTaskRunnerHandle::Get());
+ Watcher(const tracked_objects::Location& from_here,
+ scoped_refptr<base::SingleThreadTaskRunner> runner =
+ base::ThreadTaskRunnerHandle::Get());
// NOTE: This destructor automatically calls |Cancel()| if the Watcher is
// still active.
@@ -74,6 +75,12 @@ class MOJO_CPP_SYSTEM_EXPORT Watcher {
Handle handle() const { return handle_; }
ReadyCallback ready_callback() const { return callback_; }
+ // Sets the tag used by the heap profiler.
+ // |tag| must be a const string literal.
+ void set_heap_profiler_tag(const char* heap_profiler_tag) {
+ heap_profiler_tag_ = heap_profiler_tag;
+ }
+
private:
void OnHandleReady(MojoResult result);
@@ -104,6 +111,10 @@ class MOJO_CPP_SYSTEM_EXPORT Watcher {
// The callback to call when the handle is signaled.
ReadyCallback callback_;
+ // Tag used to ID memory allocations that originated from notifications in
+ // this watcher.
+ const char* heap_profiler_tag_ = nullptr;
+
base::WeakPtrFactory<Watcher> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(Watcher);
« no previous file with comments | « mojo/public/cpp/system/tests/watcher_unittest.cc ('k') | mojo/public/cpp/system/watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698