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

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

Issue 1765563002: Stream blocks of timeline events over the service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 | « runtime/vm/service_event.cc ('k') | runtime/vm/timeline.cc » ('j') | 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 #ifndef VM_TIMELINE_H_ 5 #ifndef VM_TIMELINE_H_
6 #define VM_TIMELINE_H_ 6 #define VM_TIMELINE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/bitfield.h" 9 #include "vm/bitfield.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 bool in_use() const { 519 bool in_use() const {
520 return in_use_; 520 return in_use_;
521 } 521 }
522 522
523 // Only safe to access under the recorder's lock. 523 // Only safe to access under the recorder's lock.
524 ThreadId thread_id() const { 524 ThreadId thread_id() const {
525 return thread_id_; 525 return thread_id_;
526 } 526 }
527 527
528 protected: 528 protected:
529 void PrintJSON(JSONStream* stream) const;
530
529 TimelineEvent* StartEvent(); 531 TimelineEvent* StartEvent();
530 532
531 TimelineEvent events_[kBlockSize]; 533 TimelineEvent events_[kBlockSize];
532 TimelineEventBlock* next_; 534 TimelineEventBlock* next_;
533 intptr_t length_; 535 intptr_t length_;
534 intptr_t block_index_; 536 intptr_t block_index_;
535 537
536 // Only accessed under the recorder's lock. 538 // Only accessed under the recorder's lock.
537 ThreadId thread_id_; 539 ThreadId thread_id_;
538 bool in_use_; 540 bool in_use_;
539 541
540 void Open(); 542 void Open();
541 void Finish(); 543 void Finish();
542 544
543 friend class Thread; 545 friend class Thread;
544 friend class TimelineEventRecorder; 546 friend class TimelineEventRecorder;
545 friend class TimelineEventRingRecorder; 547 friend class TimelineEventRingRecorder;
546 friend class TimelineEventEndlessRecorder; 548 friend class TimelineEventEndlessRecorder;
547 friend class TimelineTestHelper; 549 friend class TimelineTestHelper;
550 friend class JSONStream;
548 551
549 private: 552 private:
550 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock); 553 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock);
551 }; 554 };
552 555
553 556
554 class TimelineEventFilter : public ValueObject { 557 class TimelineEventFilter : public ValueObject {
555 public: 558 public:
556 TimelineEventFilter(int64_t time_origin_micros = -1, 559 TimelineEventFilter(int64_t time_origin_micros = -1,
557 int64_t time_extent_micros = -1); 560 int64_t time_extent_micros = -1);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 683
681 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); 684 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter);
682 685
683 TimelineEventBlock** blocks_; 686 TimelineEventBlock** blocks_;
684 intptr_t capacity_; 687 intptr_t capacity_;
685 intptr_t num_blocks_; 688 intptr_t num_blocks_;
686 intptr_t block_cursor_; 689 intptr_t block_cursor_;
687 }; 690 };
688 691
689 692
690 // An abstract recorder that calls |StreamEvent| whenever an event is complete. 693 // An abstract recorder that calls |OnEvent| whenever an event is complete.
691 class TimelineEventStreamingRecorder : public TimelineEventRecorder { 694 // This should only be used for testing.
695 class TimelineEventCallbackRecorder : public TimelineEventRecorder {
692 public: 696 public:
693 TimelineEventStreamingRecorder(); 697 TimelineEventCallbackRecorder();
694 ~TimelineEventStreamingRecorder(); 698 ~TimelineEventCallbackRecorder();
695 699
696 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); 700 void PrintJSON(JSONStream* js, TimelineEventFilter* filter);
697 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); 701 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter);
698 702
699 // Called when |event| is ready to be streamed. It is unsafe to keep a 703 // Called when |event| is completed. It is unsafe to keep a reference to
700 // reference to |event| as it may be freed as soon as this function returns. 704 // |event| as it may be freed as soon as this function returns.
701 virtual void StreamEvent(TimelineEvent* event) = 0; 705 virtual void OnEvent(TimelineEvent* event) = 0;
702 706
703 const char* name() const { 707 const char* name() const {
704 return "streaming"; 708 return "callback";
705 } 709 }
706 710
707 protected: 711 protected:
708 TimelineEventBlock* GetNewBlockLocked() { 712 TimelineEventBlock* GetNewBlockLocked() {
709 return NULL; 713 return NULL;
710 } 714 }
711 TimelineEventBlock* GetHeadBlockLocked() { 715 TimelineEventBlock* GetHeadBlockLocked() {
712 return NULL; 716 return NULL;
713 } 717 }
714 void Clear() { 718 void Clear() {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 768
765 private: 769 private:
766 TimelineEventBlock* current_; 770 TimelineEventBlock* current_;
767 TimelineEventRecorder* recorder_; 771 TimelineEventRecorder* recorder_;
768 }; 772 };
769 773
770 774
771 } // namespace dart 775 } // namespace dart
772 776
773 #endif // VM_TIMELINE_H_ 777 #endif // VM_TIMELINE_H_
OLDNEW
« no previous file with comments | « runtime/vm/service_event.cc ('k') | runtime/vm/timeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698