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

Side by Side Diff: mojo/common/dart/lib/tracing_helper.dart

Issue 1284293003: Rename tracing interfaces. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « mojo/common/dart/lib/trace_provider_impl.dart ('k') | mojo/common/trace_controller_impl.h » ('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 tracing; 5 library tracing;
6 6
7 import 'trace_controller_impl.dart'; 7 import 'trace_provider_impl.dart';
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:convert'; 10 import 'dart:convert';
11 import 'dart:core'; 11 import 'dart:core';
12 import 'dart:io'; 12 import 'dart:io';
13 import 'dart:isolate'; 13 import 'dart:isolate';
14 14
15 import 'package:mojo/application.dart'; 15 import 'package:mojo/application.dart';
16 import 'package:mojo/bindings.dart'; 16 import 'package:mojo/bindings.dart';
17 import 'package:mojo/core.dart'; 17 import 'package:mojo/core.dart';
18 import 'package:mojo_services/tracing/tracing.mojom.dart'; 18 import 'package:mojo_services/tracing/tracing.mojom.dart';
19 19
20 // TracingHelper is used by Dart code running in the Mojo shell in order 20 // TracingHelper is used by Dart code running in the Mojo shell in order
21 // to perform tracing. 21 // to perform tracing.
22 class TracingHelper { 22 class TracingHelper {
23 TraceControllerImpl _impl; 23 TraceProviderImpl _impl;
24 String _tid; 24 String _tid;
25 25
26 // Construct an instance of TracingHelper from within your application's 26 // Construct an instance of TracingHelper from within your application's
27 // |initialize()| method. |appName| will be used to form a thread identifier 27 // |initialize()| method. |appName| will be used to form a thread identifier
28 // for use in trace messages. If |appName| is longer than 20 characters then 28 // for use in trace messages. If |appName| is longer than 20 characters then
29 // only the last 20 characters of |appName| will be used. 29 // only the last 20 characters of |appName| will be used.
30 TracingHelper(Application app, String appName) { 30 TracingHelper(Application app, String appName) {
31 // We use only the last 20 characters of appName to form the tid so that 31 // We use only the last 20 characters of appName to form the tid so that
32 // the 9-digit Isolate hash code we are appending won't get truncated by the 32 // the 9-digit Isolate hash code we are appending won't get truncated by the
33 // tracing UI. 33 // tracing UI.
34 if (appName.length > 20) { 34 if (appName.length > 20) {
35 appName = appName.substring(appName.length - 20); 35 appName = appName.substring(appName.length - 20);
36 } 36 }
37 _tid = "${appName}/${Isolate.current.hashCode.toString()}"; 37 _tid = "${appName}/${Isolate.current.hashCode.toString()}";
38 ApplicationConnection connection = app.connectToApplication("mojo:tracing"); 38 ApplicationConnection connection = app.connectToApplication("mojo:tracing");
39 connection.provideService(TraceControllerName, (e) { 39 connection.provideService(TraceProviderName, (e) {
40 assert(_impl == null); 40 assert(_impl == null);
41 _impl = new TraceControllerImpl.fromEndpoint(e); 41 _impl = new TraceProviderImpl.fromEndpoint(e);
42 }); 42 });
43 } 43 }
44 44
45 bool isActive() { 45 bool isActive() {
46 return (_impl != null) && _impl.isActive(); 46 return (_impl != null) && _impl.isActive();
47 } 47 }
48 48
49 // Invoke this at the beginning of a function whose duration you wish to 49 // Invoke this at the beginning of a function whose duration you wish to
50 // trace. Invoke |end()| on the returned object. 50 // trace. Invoke |end()| on the returned object.
51 FunctionTrace beginFunction(String functionName, {Map<String, String> args}) { 51 FunctionTrace beginFunction(String functionName, {Map<String, String> args}) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 _FunctionTraceImpl(this._tracing, this._functionName); 101 _FunctionTraceImpl(this._tracing, this._functionName);
102 102
103 @override 103 @override
104 void end() { 104 void end() {
105 if (_functionName != null) { 105 if (_functionName != null) {
106 _tracing._endFunction(_functionName); 106 _tracing._endFunction(_functionName);
107 } 107 }
108 } 108 }
109 } 109 }
OLDNEW
« no previous file with comments | « mojo/common/dart/lib/trace_provider_impl.dart ('k') | mojo/common/trace_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698