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

Unified Diff: gin/v8_platform.cc

Issue 2650943008: [gin] Fire observer after added when recording is in progress. (Closed)
Patch Set: update 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 | « gin/BUILD.gn ('k') | gin/v8_platform_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/v8_platform.cc
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index 6e5491bff11801397e353cb371b1a9762fffb970..4fe7c7ceced0d5f4d164ea14c548aca3aba0b1d6 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -217,12 +217,18 @@ class EnabledStateObserverImpl final
}
void AddObserver(v8::Platform::TraceStateObserver* observer) {
- base::AutoLock lock(mutex_);
- DCHECK(!observers_.count(observer));
- observers_.insert(observer);
- if (observers_.size() == 1) {
- base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this);
+ {
+ base::AutoLock lock(mutex_);
+ DCHECK(!observers_.count(observer));
+ if (observers_.empty()) {
+ base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(
+ this);
+ }
+ observers_.insert(observer);
}
+ // Fire the observer if recording is already in progress.
+ if (base::trace_event::TraceLog::GetInstance()->IsEnabled())
+ observer->OnTraceEnabled();
}
void RemoveObserver(v8::Platform::TraceStateObserver* observer) {
« no previous file with comments | « gin/BUILD.gn ('k') | gin/v8_platform_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698