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

Unified Diff: base/trace_event/blame_context.h

Issue 1956333002: Change the base class of BlameContext into AsyncEnabledStateObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ThreadSafeObserver
Patch Set: Add note on thread safety for Enter() and Leave() Created 4 years, 7 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/trace_event/blame_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/blame_context.h
diff --git a/base/trace_event/blame_context.h b/base/trace_event/blame_context.h
index 81c35afc8b932e0533874dbf43beae418817e6d2..0bcb7e4c51d94e037a77c619551e531c9cbc3226 100644
--- a/base/trace_event/blame_context.h
+++ b/base/trace_event/blame_context.h
@@ -9,6 +9,7 @@
#include "base/base_export.h"
#include "base/macros.h"
+#include "base/threading/thread_checker.h"
#include "base/trace_event/trace_log.h"
namespace base {
@@ -33,7 +34,7 @@ namespace trace_event {
// should be attributed to a blame context which is the parent of all <iframe>
// blame contexts.
class BASE_EXPORT BlameContext
- : public trace_event::TraceLog::EnabledStateObserver {
+ : public trace_event::TraceLog::AsyncEnabledStateObserver {
public:
// Construct a blame context belonging to the blame context tree |name|, using
// the tracing category |category|, identified by |id| from the |scope|
@@ -75,12 +76,17 @@ class BASE_EXPORT BlameContext
void Initialize();
// Indicate that the current thread is now doing work which should count
- // against this blame context.
+ // against this blame context. This function is allowed to be called in a
+ // thread different from where the blame context was created; However, any
+ // client doing that must be fully responsible for ensuring thready safety.
void Enter();
// Leave and stop doing work for a previously entered blame context. If
// another blame context belongin to the same tree was entered prior to this
- // one, it becomes the active blame context for this thread again.
+ // one, it becomes the active blame context for this thread again. Similar
+ // to Enter(), this function can be called in a thread different from where
+ // the blame context was created, and the same requirement on thread safety
+ // must be satisfied.
void Leave();
// Record a snapshot of the blame context. This is normally only needed if a
@@ -120,6 +126,9 @@ class BASE_EXPORT BlameContext
const unsigned char* category_group_enabled_;
+ ThreadChecker thread_checker_;
+ WeakPtrFactory<BlameContext> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(BlameContext);
};
« no previous file with comments | « no previous file | base/trace_event/blame_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698