Chromium Code Reviews| Index: src/log.cc |
| diff --git a/src/log.cc b/src/log.cc |
| index 040109535b247f2cf660b7f3e5646fef23afed89..8bd05d9a1309c2521b17afd9b513d8ed46db40c4 100644 |
| --- a/src/log.cc |
| +++ b/src/log.cc |
| @@ -22,6 +22,7 @@ |
| #include "src/macro-assembler.h" |
| #include "src/perf-jit.h" |
| #include "src/profiler/cpu-profiler-inl.h" |
| +#include "src/profiler/profiler-listener.h" |
| #include "src/runtime-profiler.h" |
| #include "src/string-stream.h" |
| #include "src/vm-state-inl.h" |
| @@ -759,6 +760,7 @@ Logger::Logger(Isolate* isolate) |
| Logger::~Logger() { |
| delete log_; |
| + profiler_listener_.reset(); |
|
alph
2016/06/19 03:05:40
nit: don't need this
lpy
2016/06/20 17:16:55
Done.
|
| } |
| void Logger::addCodeEventListener(CodeEventListener* listener) { |
| @@ -1789,6 +1791,8 @@ bool Logger::SetUp(Isolate* isolate) { |
| profiler_->Engage(); |
| } |
| + profiler_listener_.reset(); |
| + |
| if (is_logging_) { |
| addCodeEventListener(this); |
| } |
| @@ -1816,6 +1820,20 @@ void Logger::SetCodeEventHandler(uint32_t options, |
| } |
| } |
| +void Logger::SetUpProfilerListener() { |
| + if (!is_initialized_) return; |
| + if (profiler_listener_.get()) { |
|
alph
2016/06/19 03:05:40
nit:
if (!listener)
listener.reset(new ...);
add
lpy
2016/06/20 17:16:55
Done.
|
| + addCodeEventListener(profiler_listener_.get()); |
| + return; |
| + } |
| + profiler_listener_.reset(new ProfilerListener(isolate_)); |
| + addCodeEventListener(profiler_listener_.get()); |
| +} |
| + |
| +void Logger::TearDownProfilerListener() { |
| + if (profiler_listener_->HasObserver()) return; |
|
alph
2016/06/19 03:05:40
maybe DCHECK(!HasObserver);
lpy
2016/06/20 17:16:55
The reason I don't put DCHECK here, is that I assu
|
| + removeCodeEventListener(profiler_listener_.get()); |
| +} |
| sampler::Sampler* Logger::sampler() { |
| return ticker_; |
| @@ -1860,6 +1878,10 @@ FILE* Logger::TearDown() { |
| jit_logger_ = NULL; |
| } |
| + if (profiler_listener_.get()) { |
|
alph
2016/06/19 03:05:40
I believe it has an implicit conversion to bool.
lpy
2016/06/20 17:16:55
Done.
|
| + removeCodeEventListener(profiler_listener_.get()); |
| + } |
| + |
| return log_->Close(); |
| } |