blob: c9a2a617eeacac08ef108fd95ebfe7becf92c89e [file] [log] [blame]
// Copyright 2019 The Cobalt Authors. All Rights Reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
interface H5vccPlatformService {
// Returns true if the given service exists on the platform, false otherwise.
static boolean has(DOMString service_name);
// Opens and returns a service with the specified name.
// Returns null if no service of the specified name exists.
// Data may be received via the |receive_callback| the moment after this
// function returns non-null.
[CallWith=EnvironmentSettings] static H5vccPlatformService? open(DOMString service_name, ReceiveCallback receive_callback);
// Sends the specified data to the service. The service
// may optionally synchronously return data. For asynchronous
// responses the service should utilize the |receive_callback|.
// If the service has been closed, then kInvalidStateErr is raised.
// If the service is open but not currently able to accept data, then
// kInvalidStateErr is raised.
[RaisesException] ArrayBuffer? send(ArrayBuffer data);
// Closes the specified service. After calling Close(), it is
// guaranteed that |receive_callback| will no longer be called, and
// subsequent calls to send() are considered errors.
void close();
// When a service is opened a callback must be registered to enable push
// communications from the service. A service may use the receive callback
// to asynchronously respond to a previous Send() call.
callback ReceiveCallback = void (H5vccPlatformService service, ArrayBuffer data);