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

Unified Diff: base/pending_task.h

Issue 2374193002: Make base::PendingTask support ConvertableToTraceFormat (Closed)
Patch Set: JsonWriter::Write requires a temp var Created 4 years, 3 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 | « no previous file | base/pending_task.cc » ('j') | base/pending_task.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pending_task.h
diff --git a/base/pending_task.h b/base/pending_task.h
index 5761653397e0e5d011522f56e786fa1cbbbcc373..81ea2e953f38576e55ea255266e24980969205f8 100644
--- a/base/pending_task.h
+++ b/base/pending_task.h
@@ -5,12 +5,15 @@
#ifndef BASE_PENDING_TASK_H_
#define BASE_PENDING_TASK_H_
+#include <memory>
#include <queue>
#include "base/base_export.h"
#include "base/callback.h"
#include "base/location.h"
+#include "base/macros.h"
#include "base/time/time.h"
+#include "base/trace_event/trace_event_impl.h"
#include "base/tracking_info.h"
namespace base {
@@ -18,6 +21,21 @@ namespace base {
// Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue
// for use by classes that queue and execute tasks.
struct BASE_EXPORT PendingTask : public TrackingInfo {
+ // A thread-safe copy of a PendingTask's info required by tracing.
+ class TracingInfo : public trace_event::ConvertableToTraceFormat {
caseq 2016/09/29 22:46:37 Why does it have to be nested class of PendingTask
gab 2016/10/03 15:18:58 Good point, I'll move it when we achieve overall c
+ public:
+ TracingInfo(const tracked_objects::Location& posted_from);
+ ~TracingInfo() override;
+
+ // Overridden from trace_event::ConvertableToTraceFormat:
+ void AppendAsTraceFormat(std::string* out) const override;
+
+ private:
+ const tracked_objects::Location posted_from_;
+
+ DISALLOW_COPY_AND_ASSIGN(TracingInfo);
+ };
+
PendingTask(const tracked_objects::Location& posted_from,
Closure task);
PendingTask(const tracked_objects::Location& posted_from,
@@ -32,6 +50,8 @@ struct BASE_EXPORT PendingTask : public TrackingInfo {
// Used to support sorting.
bool operator<(const PendingTask& other) const;
+ std::unique_ptr<trace_event::ConvertableToTraceFormat> GetTracingInfo() const;
caseq 2016/09/29 22:46:37 ditto.
gab 2016/10/03 15:18:58 Acknowledged.
+
// The task to run.
Closure task;
« no previous file with comments | « no previous file | base/pending_task.cc » ('j') | base/pending_task.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698