OLD | NEW |
1 #!mojo mojo:dart_content_handler | 1 #!mojo mojo:dart_content_handler |
2 // Copyright 2015 The Chromium Authors. All rights reserved. | 2 // Copyright 2015 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 // This example application illustrates how to use Mojo Tracing from Dart code. | 6 // This example application illustrates how to use Mojo Tracing from Dart code. |
7 // | 7 // |
8 // To run this app: | 8 // To run this app: |
9 // mojo/devtools/common/mojo_run --trace-startup \ | 9 // mojo/devtools/common/mojo_run --trace-startup \ |
10 // https://core.mojoapps.io/examples/dart/traced_application/lib/main.dart | 10 // https://core.mojoapps.io/examples/dart/traced_application/lib/main.dart |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 class TestUsingTracingApp extends Application { | 23 class TestUsingTracingApp extends Application { |
24 TracingHelper _tracing; | 24 TracingHelper _tracing; |
25 Timer _timer; | 25 Timer _timer; |
26 | 26 |
27 TestUsingTracingApp.fromHandle(MojoHandle handle) : super.fromHandle(handle); | 27 TestUsingTracingApp.fromHandle(MojoHandle handle) : super.fromHandle(handle); |
28 | 28 |
29 void initialize(List<String> args, String url) { | 29 void initialize(List<String> args, String url) { |
30 // This sets up a connection between this application and the Mojo | 30 // This sets up a connection between this application and the Mojo |
31 // tracing service. | 31 // tracing service. |
32 _tracing = | 32 _tracing = new TracingHelper.fromApplication( |
33 new TracingHelper.fromApplication(this, "example_traced_application"); | 33 this, "example_traced_application", TraceSendTiming.AT_END); |
34 _tracing.traceInstant("initialized", "traced_application"); | 34 _tracing.traceInstant("initialized", "traced_application"); |
35 | 35 |
36 // Now we schedule some random work just so we have something to trace. | 36 // Now we schedule some random work just so we have something to trace. |
37 _timer = new Timer.periodic(new Duration(seconds: 1), (t) => function1()); | 37 _timer = new Timer.periodic(new Duration(seconds: 1), (t) => function1()); |
38 | 38 |
39 onError = (() { | 39 onError = (() { |
40 if (_timer != null) { | 40 if (_timer != null) { |
41 _timer.cancel(); | 41 _timer.cancel(); |
42 } | 42 } |
43 }); | 43 }); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 Future waitForMilliseconds(int milliseconds) { | 98 Future waitForMilliseconds(int milliseconds) { |
99 return new Future.delayed(new Duration(milliseconds: milliseconds), () {}); | 99 return new Future.delayed(new Duration(milliseconds: milliseconds), () {}); |
100 } | 100 } |
101 | 101 |
102 main(List args) { | 102 main(List args) { |
103 MojoHandle appHandle = new MojoHandle(args[0]); | 103 MojoHandle appHandle = new MojoHandle(args[0]); |
104 new TestUsingTracingApp.fromHandle(appHandle); | 104 new TestUsingTracingApp.fromHandle(appHandle); |
105 } | 105 } |
OLD | NEW |