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

Side by Side Diff: sky/framework/fn.dart

Issue 1028243003: Let Dart code running in Sky add events to the trace timeline (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: more Created 5 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 | « sky/framework/components/fixed_height_scrollable.dart ('k') | sky/framework/tracing.dart » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 library fn; 5 library fn;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:sky' as sky; 9 import 'dart:sky' as sky;
10 import 'reflect.dart' as reflect; 10 import 'reflect.dart' as reflect;
11 11
12 final sky.Tracing _tracing = sky.window.tracing;
13
12 bool _initIsInCheckedMode() { 14 bool _initIsInCheckedMode() {
13 String testFn(i) { double d = i; return d.toString(); } 15 String testFn(i) { double d = i; return d.toString(); }
14 try { 16 try {
15 testFn('not a double'); 17 testFn('not a double');
16 } catch (ex) { 18 } catch (ex) {
17 return true; 19 return true;
18 } 20 }
19 return false; 21 return false;
20 } 22 }
21 23
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 _unmountedComponents.clear(); 708 _unmountedComponents.clear();
707 } finally { 709 } finally {
708 _notifingMountStatus = false; 710 _notifingMountStatus = false;
709 } 711 }
710 } 712 }
711 713
712 List<Component> _dirtyComponents = new List<Component>(); 714 List<Component> _dirtyComponents = new List<Component>();
713 bool _buildScheduled = false; 715 bool _buildScheduled = false;
714 bool _inRenderDirtyComponents = false; 716 bool _inRenderDirtyComponents = false;
715 717
718 void _buildDirtyComponents() {
719 _tracing.begin('fn::_buildDirtyComponents');
716 720
717 void _buildDirtyComponents() {
718 Stopwatch sw; 721 Stopwatch sw;
719 if (_shouldLogRenderDuration) 722 if (_shouldLogRenderDuration)
720 sw = new Stopwatch()..start(); 723 sw = new Stopwatch()..start();
721 724
722 try { 725 try {
723 _inRenderDirtyComponents = true; 726 _inRenderDirtyComponents = true;
724 727
725 _dirtyComponents.sort((a, b) => a._order - b._order); 728 _dirtyComponents.sort((a, b) => a._order - b._order);
726 for (var comp in _dirtyComponents) { 729 for (var comp in _dirtyComponents) {
727 comp._buildIfDirty(); 730 comp._buildIfDirty();
728 } 731 }
729 732
730 _dirtyComponents.clear(); 733 _dirtyComponents.clear();
731 _buildScheduled = false; 734 _buildScheduled = false;
732 } finally { 735 } finally {
733 _inRenderDirtyComponents = false; 736 _inRenderDirtyComponents = false;
734 } 737 }
735 738
736 _notifyMountStatusChanged(); 739 _notifyMountStatusChanged();
737 740
738 if (_shouldLogRenderDuration) { 741 if (_shouldLogRenderDuration) {
739 sw.stop(); 742 sw.stop();
740 print("Render took ${sw.elapsedMicroseconds} microseconds"); 743 print('Render took ${sw.elapsedMicroseconds} microseconds');
741 } 744 }
745
746 _tracing.end('fn::_buildDirtyComponents');
742 } 747 }
743 748
744 void _scheduleComponentForRender(Component c) { 749 void _scheduleComponentForRender(Component c) {
745 assert(!_inRenderDirtyComponents); 750 assert(!_inRenderDirtyComponents);
746 _dirtyComponents.add(c); 751 _dirtyComponents.add(c);
747 752
748 if (!_buildScheduled) { 753 if (!_buildScheduled) {
749 _buildScheduled = true; 754 _buildScheduled = true;
750 new Future.microtask(_buildDirtyComponents); 755 new Future.microtask(_buildDirtyComponents);
751 } 756 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 899
895 abstract class App extends Component { 900 abstract class App extends Component {
896 sky.Node _host; 901 sky.Node _host;
897 902
898 App() : super(stateful: true) { 903 App() : super(stateful: true) {
899 _host = sky.document.createElement('div'); 904 _host = sky.document.createElement('div');
900 sky.document.appendChild(_host); 905 sky.document.appendChild(_host);
901 _scheduleComponentForRender(this); 906 _scheduleComponentForRender(this);
902 } 907 }
903 } 908 }
OLDNEW
« no previous file with comments | « sky/framework/components/fixed_height_scrollable.dart ('k') | sky/framework/tracing.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698