mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
Add support for getting the sessionId from instrumentation and sending it to the client
R=scheglov@google.com Review URL: https://codereview.chromium.org/2359233002 .
This commit is contained in:
parent
1e744f3dc2
commit
74686371b3
|
@ -356,6 +356,7 @@ a:focus, a:hover {
|
||||||
"params": {
|
"params": {
|
||||||
"<b>version</b>": String
|
"<b>version</b>": String
|
||||||
"<b>pid</b>": int
|
"<b>pid</b>": int
|
||||||
|
"<b>sessionId</b>": <span style="color:#999999">optional</span> String
|
||||||
}
|
}
|
||||||
}</pre></div>
|
}</pre></div>
|
||||||
<p>
|
<p>
|
||||||
|
@ -375,6 +376,9 @@ a:focus, a:hover {
|
||||||
</dd><dt class="field"><b>pid (int)</b></dt><dd>
|
</dd><dt class="field"><b>pid (int)</b></dt><dd>
|
||||||
|
|
||||||
<p>The process id of the analysis server process.</p>
|
<p>The process id of the analysis server process.</p>
|
||||||
|
</dd><dt class="field"><b>sessionId (<span style="color:#999999">optional</span> String)</b></dt><dd>
|
||||||
|
|
||||||
|
<p>The session id for this session.</p>
|
||||||
</dd></dl></dd><dt class="notification"><a name="notification_server.error">server.error</a> (<a href="#notification_server.error">#</a>)</dt><dd><div class="box"><pre>notification: {
|
</dd></dl></dd><dt class="notification"><a name="notification_server.error">server.error</a> (<a href="#notification_server.error">#</a>)</dt><dd><div class="box"><pre>notification: {
|
||||||
"event": "server.error"
|
"event": "server.error"
|
||||||
"params": {
|
"params": {
|
||||||
|
|
|
@ -267,6 +267,7 @@ class ServerSetSubscriptionsResult {
|
||||||
* {
|
* {
|
||||||
* "version": String
|
* "version": String
|
||||||
* "pid": int
|
* "pid": int
|
||||||
|
* "sessionId": optional String
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Clients may not extend, implement or mix-in this class.
|
* Clients may not extend, implement or mix-in this class.
|
||||||
|
@ -276,6 +277,8 @@ class ServerConnectedParams implements HasToJson {
|
||||||
|
|
||||||
int _pid;
|
int _pid;
|
||||||
|
|
||||||
|
String _sessionId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The version number of the analysis server.
|
* The version number of the analysis server.
|
||||||
*/
|
*/
|
||||||
|
@ -302,9 +305,22 @@ class ServerConnectedParams implements HasToJson {
|
||||||
this._pid = value;
|
this._pid = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerConnectedParams(String version, int pid) {
|
/**
|
||||||
|
* The session id for this session.
|
||||||
|
*/
|
||||||
|
String get sessionId => _sessionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The session id for this session.
|
||||||
|
*/
|
||||||
|
void set sessionId(String value) {
|
||||||
|
this._sessionId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerConnectedParams(String version, int pid, {String sessionId}) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.pid = pid;
|
this.pid = pid;
|
||||||
|
this.sessionId = sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
factory ServerConnectedParams.fromJson(JsonDecoder jsonDecoder, String jsonPath, Object json) {
|
factory ServerConnectedParams.fromJson(JsonDecoder jsonDecoder, String jsonPath, Object json) {
|
||||||
|
@ -324,7 +340,11 @@ class ServerConnectedParams implements HasToJson {
|
||||||
} else {
|
} else {
|
||||||
throw jsonDecoder.missingKey(jsonPath, "pid");
|
throw jsonDecoder.missingKey(jsonPath, "pid");
|
||||||
}
|
}
|
||||||
return new ServerConnectedParams(version, pid);
|
String sessionId;
|
||||||
|
if (json.containsKey("sessionId")) {
|
||||||
|
sessionId = jsonDecoder.decodeString(jsonPath + ".sessionId", json["sessionId"]);
|
||||||
|
}
|
||||||
|
return new ServerConnectedParams(version, pid, sessionId: sessionId);
|
||||||
} else {
|
} else {
|
||||||
throw jsonDecoder.mismatch(jsonPath, "server.connected params", json);
|
throw jsonDecoder.mismatch(jsonPath, "server.connected params", json);
|
||||||
}
|
}
|
||||||
|
@ -339,6 +359,9 @@ class ServerConnectedParams implements HasToJson {
|
||||||
Map<String, dynamic> result = {};
|
Map<String, dynamic> result = {};
|
||||||
result["version"] = version;
|
result["version"] = version;
|
||||||
result["pid"] = pid;
|
result["pid"] = pid;
|
||||||
|
if (sessionId != null) {
|
||||||
|
result["sessionId"] = sessionId;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +376,8 @@ class ServerConnectedParams implements HasToJson {
|
||||||
bool operator==(other) {
|
bool operator==(other) {
|
||||||
if (other is ServerConnectedParams) {
|
if (other is ServerConnectedParams) {
|
||||||
return version == other.version &&
|
return version == other.version &&
|
||||||
pid == other.pid;
|
pid == other.pid &&
|
||||||
|
sessionId == other.sessionId;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -363,6 +387,7 @@ class ServerConnectedParams implements HasToJson {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
hash = JenkinsSmiHash.combine(hash, version.hashCode);
|
hash = JenkinsSmiHash.combine(hash, version.hashCode);
|
||||||
hash = JenkinsSmiHash.combine(hash, pid.hashCode);
|
hash = JenkinsSmiHash.combine(hash, pid.hashCode);
|
||||||
|
hash = JenkinsSmiHash.combine(hash, sessionId.hashCode);
|
||||||
return JenkinsSmiHash.finish(hash);
|
return JenkinsSmiHash.finish(hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,8 +376,9 @@ class AnalysisServer {
|
||||||
_setupIndexInvalidation();
|
_setupIndexInvalidation();
|
||||||
pubSummaryManager =
|
pubSummaryManager =
|
||||||
new PubSummaryManager(resourceProvider, '${io.pid}.temp');
|
new PubSummaryManager(resourceProvider, '${io.pid}.temp');
|
||||||
Notification notification =
|
Notification notification = new ServerConnectedParams(VERSION, io.pid,
|
||||||
new ServerConnectedParams(VERSION, io.pid).toNotification();
|
sessionId: instrumentationService.sessionId)
|
||||||
|
.toNotification();
|
||||||
channel.sendNotification(notification);
|
channel.sendNotification(notification);
|
||||||
channel.listen(handleRequest, onDone: done, onError: error);
|
channel.listen(handleRequest, onDone: done, onError: error);
|
||||||
handlers = serverPlugin.createDomains(this);
|
handlers = serverPlugin.createDomains(this);
|
||||||
|
|
|
@ -92,6 +92,10 @@ abstract class IntegrationTestMixin {
|
||||||
* pid (int)
|
* pid (int)
|
||||||
*
|
*
|
||||||
* The process id of the analysis server process.
|
* The process id of the analysis server process.
|
||||||
|
*
|
||||||
|
* sessionId (optional String)
|
||||||
|
*
|
||||||
|
* The session id for this session.
|
||||||
*/
|
*/
|
||||||
Stream<ServerConnectedParams> onServerConnected;
|
Stream<ServerConnectedParams> onServerConnected;
|
||||||
|
|
||||||
|
|
|
@ -66,12 +66,15 @@ final Matcher isServerSetSubscriptionsResult = isNull;
|
||||||
* {
|
* {
|
||||||
* "version": String
|
* "version": String
|
||||||
* "pid": int
|
* "pid": int
|
||||||
|
* "sessionId": optional String
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
final Matcher isServerConnectedParams = new LazyMatcher(() => new MatchesJsonObject(
|
final Matcher isServerConnectedParams = new LazyMatcher(() => new MatchesJsonObject(
|
||||||
"server.connected params", {
|
"server.connected params", {
|
||||||
"version": isString,
|
"version": isString,
|
||||||
"pid": isInt
|
"pid": isInt
|
||||||
|
}, optionalFields: {
|
||||||
|
"sessionId": isString
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,27 +32,31 @@ SCRIPT_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
||||||
|
|
||||||
ROOT_DIR="$(cd "${SCRIPT_DIR}/../../../.." ; pwd -P)"
|
ROOT_DIR="$(cd "${SCRIPT_DIR}/../../../.." ; pwd -P)"
|
||||||
|
|
||||||
BIN_DIR="${ROOT_DIR}/sdk/bin"
|
if [[ $1 == '--arch' && $2 == 'x64' ]];
|
||||||
|
then
|
||||||
if [ -z "$DART_CONFIGURATION" ];
|
DART_CONFIGURATION="ReleaseX64"
|
||||||
|
elif [ -z "$DART_CONFIGURATION" ];
|
||||||
then
|
then
|
||||||
DART_CONFIGURATION="ReleaseIA32"
|
DART_CONFIGURATION="ReleaseIA32"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ `uname` == 'Darwin' ]];
|
if [[ `uname` == 'Darwin' ]];
|
||||||
then
|
then
|
||||||
BUILD_DIR="${ROOT_DIR}/xcodebuild/$DART_CONFIGURATION"
|
if [[ $GYP_GENERATORS == 'ninja' ]];
|
||||||
else
|
then
|
||||||
BUILD_DIR="${ROOT_DIR}/out/$DART_CONFIGURATION"
|
BUILD_DIR="${ROOT_DIR}/out/$DART_CONFIGURATION"
|
||||||
|
else
|
||||||
|
BUILD_DIR="${ROOT_DIR}/xcodebuild/$DART_CONFIGURATION"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PKG_DIR="${BUILD_DIR}/packages"
|
PKG_FILE="${ROOT_DIR}/pkg/analysis_server/.packages"
|
||||||
|
|
||||||
DART="${BIN_DIR}/dart"
|
DART="${BUILD_DIR}/dart-sdk/bin/dart"
|
||||||
|
|
||||||
declare -a VM_OPTIONS
|
declare -a VM_OPTIONS
|
||||||
VM_OPTIONS+=("--checked")
|
VM_OPTIONS+=("--checked")
|
||||||
VM_OPTIONS+=("--package-root=${PKG_DIR}")
|
VM_OPTIONS+=("--packages=${PKG_FILE}")
|
||||||
|
|
||||||
cd "${SCRIPT_DIR}"
|
cd "${SCRIPT_DIR}"
|
||||||
"${DART}" "${VM_OPTIONS[@]}" "generate_all.dart"
|
"${DART}" "${VM_OPTIONS[@]}" "generate_all.dart"
|
||||||
|
|
|
@ -243,6 +243,10 @@
|
||||||
<ref>int</ref>
|
<ref>int</ref>
|
||||||
<p>The process id of the analysis server process.</p>
|
<p>The process id of the analysis server process.</p>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="sessionId" optional="true">
|
||||||
|
<ref>String</ref>
|
||||||
|
<p>The session id for this session.</p>
|
||||||
|
</field>
|
||||||
</params>
|
</params>
|
||||||
</notification>
|
</notification>
|
||||||
<notification event="error">
|
<notification event="error">
|
||||||
|
|
|
@ -20,6 +20,9 @@ class FileInstrumentationServer implements InstrumentationServer {
|
||||||
_sink = file.openWrite();
|
_sink = file.openWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get sessionId => '';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void log(String message) {
|
void log(String message) {
|
||||||
_sink.writeln(message);
|
_sink.writeln(message);
|
||||||
|
|
|
@ -22,6 +22,11 @@ class AnalysisPerformanceKind {
|
||||||
* server.
|
* server.
|
||||||
*/
|
*/
|
||||||
abstract class InstrumentationServer {
|
abstract class InstrumentationServer {
|
||||||
|
/**
|
||||||
|
* Return the identifier used to identify the current session.
|
||||||
|
*/
|
||||||
|
String get sessionId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass the given [message] to the instrumentation server so that it will be
|
* Pass the given [message] to the instrumentation server so that it will be
|
||||||
* logged with other messages.
|
* logged with other messages.
|
||||||
|
@ -95,6 +100,11 @@ class InstrumentationService {
|
||||||
*/
|
*/
|
||||||
bool get isActive => _instrumentationServer != null;
|
bool get isActive => _instrumentationServer != null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the identifier used to identify the current session.
|
||||||
|
*/
|
||||||
|
String get sessionId => _instrumentationServer?.sessionId ?? '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current time, expressed as a decimal encoded number of milliseconds.
|
* The current time, expressed as a decimal encoded number of milliseconds.
|
||||||
*/
|
*/
|
||||||
|
@ -356,6 +366,9 @@ class MulticastInstrumentationServer implements InstrumentationServer {
|
||||||
|
|
||||||
MulticastInstrumentationServer(this._servers);
|
MulticastInstrumentationServer(this._servers);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get sessionId => _servers[0].sessionId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void log(String message) {
|
void log(String message) {
|
||||||
for (InstrumentationServer server in _servers) {
|
for (InstrumentationServer server in _servers) {
|
||||||
|
|
|
@ -164,6 +164,9 @@ class TestInstrumentationServer implements InstrumentationServer {
|
||||||
StringBuffer normalChannel = new StringBuffer();
|
StringBuffer normalChannel = new StringBuffer();
|
||||||
StringBuffer priorityChannel = new StringBuffer();
|
StringBuffer priorityChannel = new StringBuffer();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get sessionId => '';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void log(String message) {
|
void log(String message) {
|
||||||
normalChannel.writeln(message);
|
normalChannel.writeln(message);
|
||||||
|
|
Loading…
Reference in a new issue