Chromium Code Reviews| Index: pkg/analysis_server/lib/src/channel/byte_stream_channel.dart |
| diff --git a/pkg/analysis_server/lib/src/channel/byte_stream_channel.dart b/pkg/analysis_server/lib/src/channel/byte_stream_channel.dart |
| index 884dcd25c0a3e1cd7c7386c7ea94e5af0e5efc2a..c03712fec40a6c09d2b11670d9c61843e5b3adec 100644 |
| --- a/pkg/analysis_server/lib/src/channel/byte_stream_channel.dart |
| +++ b/pkg/analysis_server/lib/src/channel/byte_stream_channel.dart |
| @@ -8,9 +8,11 @@ import 'dart:async'; |
| import 'dart:convert'; |
| import 'dart:io'; |
| +import 'package:analysis_server/src/analysis_server.dart'; |
| import 'package:analysis_server/src/channel/channel.dart'; |
| import 'package:analysis_server/src/protocol.dart'; |
| import 'package:analyzer/instrumentation/instrumentation.dart'; |
| +import 'package:analyzer/src/generated/utilities_general.dart'; |
| /** |
| * Instances of the class [ByteStreamClientChannel] implement a |
| @@ -120,11 +122,15 @@ class ByteStreamServerChannel implements ServerCommunicationChannel { |
| if (_closeRequested) { |
| return; |
| } |
| - ServerCommunicationChannel.ToJson.start(); |
| - String jsonEncoding = JSON.encode(notification.toJson()); |
| - ServerCommunicationChannel.ToJson.stop(); |
| - _outputLine(jsonEncoding); |
| - _instrumentationService.logNotification(jsonEncoding); |
| + PerformanceTag prevTag = |
| + ServerPerformanceStatistics.serverChannel.makeCurrent(); |
| + try { |
| + String jsonEncoding = JSON.encode(notification.toJson()); |
| + _outputLine(jsonEncoding); |
| + _instrumentationService.logNotification(jsonEncoding); |
| + } finally { |
| + prevTag.makeCurrent(); |
| + } |
|
Brian Wilkerson
2015/02/24 20:07:29
There's a lot of boiler-plate here. How about some
scheglov
2015/02/24 21:49:04
Will do in a separate CL.
|
| } |
| @override |
| @@ -134,11 +140,15 @@ class ByteStreamServerChannel implements ServerCommunicationChannel { |
| if (_closeRequested) { |
| return; |
| } |
| - ServerCommunicationChannel.ToJson.start(); |
| - String jsonEncoding = JSON.encode(response.toJson()); |
| - ServerCommunicationChannel.ToJson.stop(); |
| - _outputLine(jsonEncoding); |
| - _instrumentationService.logResponse(jsonEncoding); |
| + PerformanceTag prevTag = |
| + ServerPerformanceStatistics.serverChannel.makeCurrent(); |
| + try { |
| + String jsonEncoding = JSON.encode(response.toJson()); |
| + _outputLine(jsonEncoding); |
| + _instrumentationService.logResponse(jsonEncoding); |
| + } finally { |
| + prevTag.makeCurrent(); |
| + } |
| } |
| /** |
| @@ -157,16 +167,20 @@ class ByteStreamServerChannel implements ServerCommunicationChannel { |
| if (_closed.isCompleted) { |
| return; |
| } |
| - _instrumentationService.logRequest(data); |
| - // Parse the string as a JSON descriptor and process the resulting |
| - // structure as a request. |
| - ServerCommunicationChannel.FromJson.start(); |
| - Request request = new Request.fromString(data); |
| - ServerCommunicationChannel.FromJson.stop(); |
| - if (request == null) { |
| - sendResponse(new Response.invalidRequestFormat()); |
| - return; |
| + PerformanceTag prevTag = |
| + ServerPerformanceStatistics.serverChannel.makeCurrent(); |
| + try { |
| + _instrumentationService.logRequest(data); |
| + // Parse the string as a JSON descriptor and process the resulting |
| + // structure as a request. |
| + Request request = new Request.fromString(data); |
| + if (request == null) { |
| + sendResponse(new Response.invalidRequestFormat()); |
| + return; |
| + } |
| + onRequest(request); |
| + } finally { |
| + prevTag.makeCurrent(); |
| } |
| - onRequest(request); |
| } |
| } |