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

Unified Diff: pkg/analysis_server/lib/src/protocol.dart

Issue 865383002: add optional request field to record time at which client made request (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/protocol.dart
diff --git a/pkg/analysis_server/lib/src/protocol.dart b/pkg/analysis_server/lib/src/protocol.dart
index 95eb38c972a9d7aff2d57dc488c74189b50b6032..a68a9904623f3020a7cf770ae3a7688e83dcabac 100644
--- a/pkg/analysis_server/lib/src/protocol.dart
+++ b/pkg/analysis_server/lib/src/protocol.dart
@@ -497,6 +497,12 @@ class Request {
static const String PARAMS = 'params';
/**
+ * The name of the optional JSON attribute indicating the time
+ * (milliseconds since epoch) at which the client made the request.
+ */
+ static const String CLIENT_REQUEST_TIME = 'clientRequestTime';
+
+ /**
* The unique identifier used to identify this request.
*/
final String id;
@@ -512,11 +518,18 @@ class Request {
final Map<String, Object> _params;
/**
+ * The time (milliseconds since epoch) at which the client made the request
+ * or `null` if this information is not provided by the client.
+ */
+ final int clientRequestTime;
+
+ /**
* Initialize a newly created [Request] to have the given [id] and [method]
* name. If [params] is supplied, it is used as the "params" map for the
* request. Otherwise an empty "params" map is allocated.
*/
- Request(this.id, this.method, [Map<String, Object> params])
+ Request(this.id, this.method, [Map<String, Object> params,
+ this.clientRequestTime])
: _params = params != null ? params : new HashMap<String, Object>();
/**
@@ -548,7 +561,8 @@ class Request {
}
var params = result[Request.PARAMS];
if (params is Map || params == null) {
- return new Request(id, method, params);
+ var time = result[Request.CLIENT_REQUEST_TIME];
+ return new Request(id, method, params, time is int ? time : null);
} else {
return null;
}
@@ -568,6 +582,9 @@ class Request {
if (_params.isNotEmpty) {
jsonObject[PARAMS] = _params;
}
+ if (clientRequestTime != null) {
+ jsonObject[CLIENT_REQUEST_TIME] = clientRequestTime;
+ }
return jsonObject;
}
}
@@ -691,6 +708,17 @@ class Response {
: _result = result;
/**
+ * Initialize a newly created instance to represent the
+ * FORMAT_INVALID_FILE error condition.
+ */
+ Response.formatInvalidFile(Request request)
+ : this(
+ request.id,
+ error: new RequestError(
+ RequestErrorCode.FORMAT_INVALID_FILE,
+ 'Error during `edit.format`: invalid file.'));
+
+ /**
* Initialize a newly created instance based upon the given JSON data
*/
factory Response.fromJson(Map<String, Object> json) {
@@ -718,17 +746,6 @@ class Response {
/**
* Initialize a newly created instance to represent the
- * FORMAT_INVALID_FILE error condition.
- */
- Response.formatInvalidFile(Request request)
- : this(
- request.id,
- error: new RequestError(
- RequestErrorCode.FORMAT_INVALID_FILE,
- 'Error during `edit.format`: invalid file.'));
-
- /**
- * Initialize a newly created instance to represent the
* GET_ERRORS_INVALID_FILE error condition.
*/
Response.getErrorsInvalidFile(Request request)

Powered by Google App Engine
This is Rietveld 408576698