| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| // API exposed by the diagnosticsd daemon. Normally the consumer of this API is |
| // the browser. |
| |
| // NOTE: This mojom should be kept in sync with the copy in Chromium's repo in |
| // src/chrome/services/diagnosticsd/public/mojom/diagnosticsd.mojom. |
| |
| module chromeos.diagnosticsd.mojom; |
| |
| [Extensible] |
| enum DiagnosticsdWebRequestHttpMethod { |
| kGet, |
| kHead, |
| kPost, |
| kPut, |
| }; |
| |
| [Extensible] |
| enum DiagnosticsdWebRequestStatus { |
| // The request was successfully completed with a 2xx HTTP status. |
| kOk, |
| // Failed to make the web request. This covers such cases when the network |
| // is unavailable, or connection attempt failed, or TLS handshake failed, |
| // or too many pending requests, etc. |
| kNetworkError, |
| // HTTP request finished with a non-2xx status. |
| kHttpError, |
| }; |
| |
| // Factory interface exposed by the diagnosticsd daemon, which allows both |
| // endpoints (the diagnosticsd and the browser) to exchange with their |
| // interfaces (DiagnosticsdService and DiagnosticsdClient correspondingly). |
| interface DiagnosticsdServiceFactory { |
| // Returns an interface to DiagnosticsdService in response to the passed |
| // interface to DiagnosticsdClient. |
| GetService@0(DiagnosticsdService& service, DiagnosticsdClient client) => (); |
| }; |
| |
| // Interface exposed by the diagnosticsd daemon. |
| interface DiagnosticsdService { |
| // Sends a message, originating from the diagnostics UI extension (hosted by |
| // the browser), to the diagnostics_processor daemon. The message contents are |
| // serialized JSON. Delivery of the message is not guaranteed (for example, if |
| // the diagnostics_processor daemon isn't running at the moment). |
| // |
| // The response will contain the JSON message returned by the |
| // diagnostics_processor daemon. The response handle will be unset if the |
| // request wasn't delivered to the daemon or the daemon made no reply. |
| SendUiMessageToDiagnosticsProcessor@0(handle json_message) |
| => (handle? response_json_message); |
| }; |
| |
| // Interface exposed by the consumer of DiagnosticsdService. In production this |
| // is the browser. |
| interface DiagnosticsdClient { |
| // Performs a web request, originating from the diagnostics_processor daemon, |
| // by the browser's network stack. |
| // |
| // The web request: |
| // * |http_method| - the HTTP method of the web request, |
| // * |url| - the URL with HTTPS scheme. |
| // * |headers| - the list of HTTP headers. |
| // * |request_body| - the body of the HTTP request. |
| // NOTE: the total size of all |handle| fields in the request must not exceed |
| // 1MB (1'000'000 bytes). |
| // |
| // The response to that web request: |
| // * the |status| of the web request, |
| // * |http_status| - the HTTP status code if the |status| is |kOk| or |
| // |kHttpError|, otherwise the HTTP status code is 0. |
| // * |response_body| - the web response payload. The handle is valid only |
| // if |status| is |kOk| or |kHttpError|. And the length |
| // is guaranteed to not exceed 1MB (1'000'000 bytes). |
| PerformWebRequest@0(DiagnosticsdWebRequestHttpMethod http_method, handle url, |
| array<handle> headers, handle? request_body) |
| => (DiagnosticsdWebRequestStatus status, int32 http_status, |
| handle? response_body); |
| |
| // Sends a message, originating from the diagnostics_processor daemon, to the |
| // diagnositcs UI extension (hosted by the browser). The message contents are |
| // serialized JSON. Delivery of the message is not guaranteed (for example, if |
| // no user is currently logged in that has the diagnostics UI extension |
| // installed). |
| // |
| // The response will contain the JSON message returned by the |
| // diagnostics_processor daemon. The response handle will be unset if the |
| // request wasn't delivered to the extension or the extension made no reply. |
| SendDiagnosticsProcessorMessageToUi@1(handle json_message) |
| => (handle? response_json_message); |
| }; |