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

Side by Side Diff: runtime/observatory/lib/src/repositories/sample_profile.dart

Issue 2999763002: Clear analyzer warning on Observatory (Closed)
Patch Set: Created 3 years, 4 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 part of repositories; 5 part of repositories;
6 6
7 String _tagToString(M.SampleProfileTag tag) { 7 String _tagToString(M.SampleProfileTag tag) {
8 switch (tag) { 8 switch (tag) {
9 case M.SampleProfileTag.userVM: 9 case M.SampleProfileTag.userVM:
10 return 'UserVM'; 10 return 'UserVM';
(...skipping 14 matching lines...) Expand all
25 final SampleProfileLoadingProgress progress; 25 final SampleProfileLoadingProgress progress;
26 SampleProfileLoadingProgressEvent(this.progress); 26 SampleProfileLoadingProgressEvent(this.progress);
27 } 27 }
28 28
29 class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress { 29 class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress {
30 StreamController<SampleProfileLoadingProgressEvent> _onProgress = 30 StreamController<SampleProfileLoadingProgressEvent> _onProgress =
31 new StreamController<SampleProfileLoadingProgressEvent>.broadcast(); 31 new StreamController<SampleProfileLoadingProgressEvent>.broadcast();
32 Stream<SampleProfileLoadingProgressEvent> get onProgress => 32 Stream<SampleProfileLoadingProgressEvent> get onProgress =>
33 _onProgress.stream; 33 _onProgress.stream;
34 34
35 final M.ServiceObjectOwner owner; 35 final S.ServiceObjectOwner owner;
36 final S.Class cls; 36 final S.Class cls;
37 final M.SampleProfileTag tag; 37 final M.SampleProfileTag tag;
38 final bool clear; 38 final bool clear;
39 final M.SampleProfileType type; 39 final M.SampleProfileType type;
40 40
41 M.SampleProfileLoadingStatus _status = M.SampleProfileLoadingStatus.fetching; 41 M.SampleProfileLoadingStatus _status = M.SampleProfileLoadingStatus.fetching;
42 double _progress = 0.0; 42 double _progress = 0.0;
43 final Stopwatch _fetchingTime = new Stopwatch(); 43 final Stopwatch _fetchingTime = new Stopwatch();
44 final Stopwatch _loadingTime = new Stopwatch(); 44 final Stopwatch _loadingTime = new Stopwatch();
45 CpuProfile _profile; 45 SampleProfile _profile;
46 46
47 M.SampleProfileLoadingStatus get status => _status; 47 M.SampleProfileLoadingStatus get status => _status;
48 double get progress => _progress; 48 double get progress => _progress;
49 Duration get fetchingTime => _fetchingTime.elapsed; 49 Duration get fetchingTime => _fetchingTime.elapsed;
50 Duration get loadingTime => _loadingTime.elapsed; 50 Duration get loadingTime => _loadingTime.elapsed;
51 CpuProfile get profile => _profile; 51 SampleProfile get profile => _profile;
52 52
53 SampleProfileLoadingProgress(this.owner, this.tag, this.clear, 53 SampleProfileLoadingProgress(this.owner, this.tag, this.clear,
54 {this.type: M.SampleProfileType.cpu, this.cls}) { 54 {this.type: M.SampleProfileType.cpu, this.cls}) {
55 _run(); 55 _run();
56 } 56 }
57 57
58 Future _run() async { 58 Future _run() async {
59 _fetchingTime.start(); 59 _fetchingTime.start();
60 try { 60 try {
61 if (clear && (type == M.SampleProfileType.cpu)) { 61 if (clear && (type == M.SampleProfileType.cpu)) {
(...skipping 12 matching lines...) Expand all
74 '_getNativeAllocationSamples', {'tags': _tagToString(tag)}); 74 '_getNativeAllocationSamples', {'tags': _tagToString(tag)});
75 } else { 75 } else {
76 throw new Exception('Unknown M.SampleProfileType: $type'); 76 throw new Exception('Unknown M.SampleProfileType: $type');
77 } 77 }
78 78
79 _fetchingTime.stop(); 79 _fetchingTime.stop();
80 _loadingTime.start(); 80 _loadingTime.start();
81 _status = M.SampleProfileLoadingStatus.loading; 81 _status = M.SampleProfileLoadingStatus.loading;
82 _triggerOnProgress(); 82 _triggerOnProgress();
83 83
84 CpuProfile profile = new CpuProfile(); 84 SampleProfile profile = new SampleProfile();
85 85
86 Stream<double> progress = profile.loadProgress(owner, response); 86 Stream<double> progress = profile.loadProgress(owner, response);
87 progress.listen((value) { 87 progress.listen((value) {
88 _progress = value; 88 _progress = value;
89 _triggerOnProgress(); 89 _triggerOnProgress();
90 }); 90 });
91 91
92 await progress.drain(); 92 await progress.drain();
93 93
94 profile.buildFunctionCallerAndCallees(); 94 profile.buildFunctionCallerAndCallees();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 _last.reuse(); 139 _last.reuse();
140 } else { 140 } else {
141 _last = new SampleProfileLoadingProgress(isolate, t, clear); 141 _last = new SampleProfileLoadingProgress(isolate, t, clear);
142 } 142 }
143 return _last.onProgress; 143 return _last.onProgress;
144 } 144 }
145 } 145 }
146 146
147 class ClassSampleProfileRepository implements M.ClassSampleProfileRepository { 147 class ClassSampleProfileRepository implements M.ClassSampleProfileRepository {
148 Stream<SampleProfileLoadingProgressEvent> get( 148 Stream<SampleProfileLoadingProgressEvent> get(
149 M.Isolate i, M.ClassRef c, M.SampleProfileTag t) { 149 M.Isolate i, M.ClassRef c, M.SampleProfileTag t,
150 {bool clear: false, bool forceFetch: false}) {
150 S.Isolate isolate = i as S.Isolate; 151 S.Isolate isolate = i as S.Isolate;
151 S.Class cls = c as S.Class; 152 S.Class cls = c as S.Class;
152 assert(isolate != null); 153 assert(isolate != null);
153 assert(cls != null); 154 assert(cls != null);
154 return new SampleProfileLoadingProgress(isolate, t, false, cls: cls) 155 return new SampleProfileLoadingProgress(isolate, t, false, cls: cls)
155 .onProgress; 156 .onProgress;
156 } 157 }
157 158
158 Future enable(M.IsolateRef i, M.ClassRef c) { 159 Future enable(M.IsolateRef i, M.ClassRef c) {
159 S.Class cls = c as S.Class; 160 S.Class cls = c as S.Class;
160 assert(cls != null); 161 assert(cls != null);
161 return cls.setTraceAllocations(true); 162 return cls.setTraceAllocations(true);
162 } 163 }
163 164
164 Future disable(M.IsolateRef i, M.ClassRef c) { 165 Future disable(M.IsolateRef i, M.ClassRef c) {
165 S.Class cls = c as S.Class; 166 S.Class cls = c as S.Class;
166 assert(cls != null); 167 assert(cls != null);
167 return cls.setTraceAllocations(false); 168 return cls.setTraceAllocations(false);
168 } 169 }
169 } 170 }
170 171
171 class NativeMemorySampleProfileRepository 172 class NativeMemorySampleProfileRepository
172 implements M.NativeMemorySampleProfileRepository { 173 implements M.NativeMemorySampleProfileRepository {
173 SampleProfileLoadingProgress _last; 174 SampleProfileLoadingProgress _last;
174 175
175 Stream<SampleProfileLoadingProgressEvent> get(M.VM vm, M.SampleProfileTag t, 176 Stream<SampleProfileLoadingProgressEvent> get(M.VM vm, M.SampleProfileTag t,
176 {bool forceFetch: false, bool clear: false}) { 177 {bool forceFetch: false, bool clear: false}) {
177 assert(forceFetch != null); 178 assert(forceFetch != null);
179 S.VM owner = vm as S.VM;
180 assert(owner != null);
181
178 if ((_last != null) && !forceFetch) { 182 if ((_last != null) && !forceFetch) {
179 _last.reuse(); 183 _last.reuse();
180 } else { 184 } else {
181 _last = new SampleProfileLoadingProgress(vm, t, false, 185 _last = new SampleProfileLoadingProgress(owner, t, false,
182 type: M.SampleProfileType.memory); 186 type: M.SampleProfileType.memory);
183 } 187 }
184 return _last.onProgress; 188 return _last.onProgress;
185 } 189 }
186 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698