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

Side by Side Diff: pkg/analyzer/lib/instrumentation/instrumentation.dart

Issue 2359233002: Add support for getting the sessionId from instrumentation and sending it to the client (Closed)
Patch Set: Created 4 years, 2 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) 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 analyzer.instrumentation.instrumentation; 5 library analyzer.instrumentation.instrumentation;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:analyzer/task/model.dart'; 10 import 'package:analyzer/task/model.dart';
11 11
12 /** 12 /**
13 * A container with analysis performance constants. 13 * A container with analysis performance constants.
14 */ 14 */
15 class AnalysisPerformanceKind { 15 class AnalysisPerformanceKind {
16 static const String FULL = 'analysis_full'; 16 static const String FULL = 'analysis_full';
17 static const String INCREMENTAL = 'analysis_incremental'; 17 static const String INCREMENTAL = 'analysis_incremental';
18 } 18 }
19 19
20 /** 20 /**
21 * The interface used by client code to communicate with an instrumentation 21 * The interface used by client code to communicate with an instrumentation
22 * server. 22 * server.
23 */ 23 */
24 abstract class InstrumentationServer { 24 abstract class InstrumentationServer {
25 /** 25 /**
26 * Return the identifier used to identify the current session.
27 */
28 String get sessionId;
29
30 /**
26 * Pass the given [message] to the instrumentation server so that it will be 31 * Pass the given [message] to the instrumentation server so that it will be
27 * logged with other messages. 32 * logged with other messages.
28 * 33 *
29 * This method should be used for most logging. 34 * This method should be used for most logging.
30 */ 35 */
31 void log(String message); 36 void log(String message);
32 37
33 /** 38 /**
34 * Pass the given [message] to the instrumentation server so that it will be 39 * Pass the given [message] to the instrumentation server so that it will be
35 * logged with other messages. 40 * logged with other messages.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 */ 94 */
90 InstrumentationService(this._instrumentationServer); 95 InstrumentationService(this._instrumentationServer);
91 96
92 /** 97 /**
93 * Return `true` if this [InstrumentationService] was initialized with a 98 * Return `true` if this [InstrumentationService] was initialized with a
94 * non-`null` server (and hence instrumentation is active). 99 * non-`null` server (and hence instrumentation is active).
95 */ 100 */
96 bool get isActive => _instrumentationServer != null; 101 bool get isActive => _instrumentationServer != null;
97 102
98 /** 103 /**
104 * Return the identifier used to identify the current session.
105 */
106 String get sessionId => _instrumentationServer?.sessionId ?? '';
107
108 /**
99 * The current time, expressed as a decimal encoded number of milliseconds. 109 * The current time, expressed as a decimal encoded number of milliseconds.
100 */ 110 */
101 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); 111 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString();
102 112
103 /** 113 /**
104 * Log that the given analysis [task] is being performed in the given 114 * Log that the given analysis [task] is being performed in the given
105 * [context]. 115 * [context].
106 */ 116 */
107 void logAnalysisTask(String context, AnalysisTask task) { 117 void logAnalysisTask(String context, AnalysisTask task) {
108 if (_instrumentationServer != null) { 118 if (_instrumentationServer != null) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 360
351 /** 361 /**
352 * An [InstrumentationServer] that sends messages to multiple instances. 362 * An [InstrumentationServer] that sends messages to multiple instances.
353 */ 363 */
354 class MulticastInstrumentationServer implements InstrumentationServer { 364 class MulticastInstrumentationServer implements InstrumentationServer {
355 final List<InstrumentationServer> _servers; 365 final List<InstrumentationServer> _servers;
356 366
357 MulticastInstrumentationServer(this._servers); 367 MulticastInstrumentationServer(this._servers);
358 368
359 @override 369 @override
370 String get sessionId => _servers[0].sessionId;
371
372 @override
360 void log(String message) { 373 void log(String message) {
361 for (InstrumentationServer server in _servers) { 374 for (InstrumentationServer server in _servers) {
362 server.log(message); 375 server.log(message);
363 } 376 }
364 } 377 }
365 378
366 @override 379 @override
367 void logWithPriority(String message) { 380 void logWithPriority(String message) {
368 for (InstrumentationServer server in _servers) { 381 for (InstrumentationServer server in _servers) {
369 server.logWithPriority(message); 382 server.logWithPriority(message);
370 } 383 }
371 } 384 }
372 385
373 @override 386 @override
374 Future shutdown() async { 387 Future shutdown() async {
375 for (InstrumentationServer server in _servers) { 388 for (InstrumentationServer server in _servers) {
376 await server.shutdown(); 389 await server.shutdown();
377 } 390 }
378 } 391 }
379 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698