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

Side by Side Diff: runtime/vm/timeline.cc

Issue 1836303002: Timeline: If the embedder stream is enabled at startup, invoke the embedder's callback to let it kn… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <cstdlib> 5 #include <cstdlib>
6 6
7 #include "vm/atomic.h" 7 #include "vm/atomic.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/json_stream.h" 9 #include "vm/json_stream.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 enabled_streams_ = GetEnabledByDefaultTimelineStreams(); 140 enabled_streams_ = GetEnabledByDefaultTimelineStreams();
141 // Global overrides. 141 // Global overrides.
142 #define TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \ 142 #define TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \
143 stream_##name##_enabled_ = HasStream(enabled_streams_, #name); \ 143 stream_##name##_enabled_ = HasStream(enabled_streams_, #name); \
144 stream_##name##_.Init(#name, \ 144 stream_##name##_.Init(#name, \
145 stream_##name##_enabled_, \ 145 stream_##name##_enabled_, \
146 &stream_##name##_enabled_); 146 &stream_##name##_enabled_);
147 TIMELINE_STREAM_LIST(TIMELINE_STREAM_FLAG_DEFAULT) 147 TIMELINE_STREAM_LIST(TIMELINE_STREAM_FLAG_DEFAULT)
148 #undef TIMELINE_STREAM_FLAG_DEFAULT 148 #undef TIMELINE_STREAM_FLAG_DEFAULT
149
150 if (stream_Embedder_enabled_ &&
151 (Timeline::get_start_recording_cb() != NULL)) {
152 Timeline::get_start_recording_cb()();
153 }
149 } 154 }
150 155
151 156
152 void Timeline::StreamStateChange(const char* stream_name, 157 void Timeline::StreamStateChange(const char* stream_name,
153 bool prev, 158 bool prev,
154 bool curr) { 159 bool curr) {
155 if (prev == curr) { 160 if (prev == curr) {
156 return; 161 return;
157 } 162 }
158 if (strcmp(stream_name, "Embedder") == 0) { 163 if (strcmp(stream_name, "Embedder") == 0) {
159 if (curr && (Timeline::get_start_recording_cb() != NULL)) { 164 if (curr && (Timeline::get_start_recording_cb() != NULL)) {
160 Timeline::get_start_recording_cb()(); 165 Timeline::get_start_recording_cb()();
161 } else if (!curr && (Timeline::get_stop_recording_cb() != NULL)) { 166 } else if (!curr && (Timeline::get_stop_recording_cb() != NULL)) {
162 Timeline::get_stop_recording_cb()(); 167 Timeline::get_stop_recording_cb()();
163 } 168 }
164 } 169 }
165 } 170 }
166 171
167 172
168 void Timeline::Shutdown() { 173 void Timeline::Shutdown() {
169 ASSERT(recorder_ != NULL); 174 ASSERT(recorder_ != NULL);
175
176 if (stream_Embedder_enabled_ &&
177 (Timeline::get_stop_recording_cb() != NULL)) {
178 Timeline::get_stop_recording_cb()();
179 }
180
170 if (FLAG_timeline_dir != NULL) { 181 if (FLAG_timeline_dir != NULL) {
171 recorder_->WriteTo(FLAG_timeline_dir); 182 recorder_->WriteTo(FLAG_timeline_dir);
172 } 183 }
184
173 // Disable global streams. 185 // Disable global streams.
174 #define TIMELINE_STREAM_DISABLE(name, not_used) \ 186 #define TIMELINE_STREAM_DISABLE(name, not_used) \
175 stream_##name##_enabled_ = false; 187 stream_##name##_enabled_ = false;
176 TIMELINE_STREAM_LIST(TIMELINE_STREAM_DISABLE) 188 TIMELINE_STREAM_LIST(TIMELINE_STREAM_DISABLE)
177 #undef TIMELINE_STREAM_DISABLE 189 #undef TIMELINE_STREAM_DISABLE
178 delete recorder_; 190 delete recorder_;
179 recorder_ = NULL; 191 recorder_ = NULL;
180 if (enabled_streams_ != NULL) { 192 if (enabled_streams_ != NULL) {
181 FreeEnabledByDefaultTimelineStreams(enabled_streams_); 193 FreeEnabledByDefaultTimelineStreams(enabled_streams_);
182 enabled_streams_ = NULL; 194 enabled_streams_ = NULL;
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 TimelineEventBlock* TimelineEventBlockIterator::Next() { 1516 TimelineEventBlock* TimelineEventBlockIterator::Next() {
1505 ASSERT(current_ != NULL); 1517 ASSERT(current_ != NULL);
1506 TimelineEventBlock* r = current_; 1518 TimelineEventBlock* r = current_;
1507 current_ = current_->next(); 1519 current_ = current_->next();
1508 return r; 1520 return r;
1509 } 1521 }
1510 1522
1511 #endif // !PRODUCT 1523 #endif // !PRODUCT
1512 1524
1513 } // namespace dart 1525 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698