| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library instrumentation; | 5 library instrumentation; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The interface used by client code to communicate with an instrumentation | 8 * The interface used by client code to communicate with an instrumentation |
| 9 * server. | 9 * server. |
| 10 */ | 10 */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * The interface used by client code to communicate with an instrumentation | 38 * The interface used by client code to communicate with an instrumentation |
| 39 * server by wrapping an [InstrumentationServer]. | 39 * server by wrapping an [InstrumentationServer]. |
| 40 */ | 40 */ |
| 41 class InstrumentationService { | 41 class InstrumentationService { |
| 42 /** | 42 /** |
| 43 * An instrumentation service that will not log any instrumentation data. | 43 * An instrumentation service that will not log any instrumentation data. |
| 44 */ | 44 */ |
| 45 static const InstrumentationService NULL_SERVICE = | 45 static final InstrumentationService NULL_SERVICE = |
| 46 const InstrumentationService(null); | 46 new InstrumentationService(null); |
| 47 | 47 |
| 48 static const String TAG_NOTIFICATION = 'Noti'; | 48 static const String TAG_NOTIFICATION = 'Noti'; |
| 49 static const String TAG_REQUEST = 'Req'; | 49 static const String TAG_REQUEST = 'Req'; |
| 50 static const String TAG_RESPONSE = 'Res'; | 50 static const String TAG_RESPONSE = 'Res'; |
| 51 static const String TAG_VERSION = 'Ver'; | 51 static const String TAG_VERSION = 'Ver'; |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * The instrumentation server used to communicate with the server, or `null` | 54 * The instrumentation server used to communicate with the server, or `null` |
| 55 * if instrumentation data should not be logged. | 55 * if instrumentation data should not be logged. |
| 56 */ | 56 */ |
| 57 final InstrumentationServer instrumentationServer; | 57 InstrumentationServer _instrumentationServer; |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Initialize a newly created instrumentation service to comunicate with the | 60 * Initialize a newly created instrumentation service to comunicate with the |
| 61 * given [instrumentationServer]. | 61 * given [instrumentationServer]. |
| 62 */ | 62 */ |
| 63 const InstrumentationService(this.instrumentationServer); | 63 InstrumentationService(this._instrumentationServer); |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * The current time, expressed as a decimal encoded number of milliseconds. | 66 * The current time, expressed as a decimal encoded number of milliseconds. |
| 67 */ | 67 */ |
| 68 String get _timestamp => new DateTime.now().millisecond.toString(); | 68 String get _timestamp => new DateTime.now().millisecond.toString(); |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * Log that a notification has been sent to the client. | 71 * Log that a notification has been sent to the client. |
| 72 */ | 72 */ |
| 73 void logNotification(String notification) { | 73 void logNotification(String notification) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 87 void logResponse(String response) { | 87 void logResponse(String response) { |
| 88 _log(TAG_RESPONSE, response); | 88 _log(TAG_RESPONSE, response); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Signal that the client is done communicating with the instrumentation | 92 * Signal that the client is done communicating with the instrumentation |
| 93 * server. This method should be invoked exactly one time and no other methods | 93 * server. This method should be invoked exactly one time and no other methods |
| 94 * should be invoked on this instance after this method has been invoked. | 94 * should be invoked on this instance after this method has been invoked. |
| 95 */ | 95 */ |
| 96 void shutdown() { | 96 void shutdown() { |
| 97 if (instrumentationServer != null) { | 97 if (_instrumentationServer != null) { |
| 98 instrumentationServer.shutdown(); | 98 _instrumentationServer.shutdown(); |
| 99 _instrumentationServer = null; |
| 99 } | 100 } |
| 100 } | 101 } |
| 101 | 102 |
| 102 /** | 103 /** |
| 103 * Log the given message with the given tag. | 104 * Log the given message with the given tag. |
| 104 */ | 105 */ |
| 105 void _log(String tag, String message) { | 106 void _log(String tag, String message) { |
| 106 if (instrumentationServer != null) { | 107 if (_instrumentationServer != null) { |
| 107 instrumentationServer.log('$_timestamp:$tag:$message'); | 108 _instrumentationServer.log('$_timestamp:$tag:$message'); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 } | 111 } |
| OLD | NEW |