#include "services/webnn/webnn_context_impl.h"
#include <memory>
#include <utility>
#include "base/sequence_checker.h"
#include "services/webnn/error.h"
#include "services/webnn/public/cpp/graph_validation_utils.h"
#include "services/webnn/public/cpp/operand_descriptor.h"
#include "services/webnn/public/cpp/supported_data_types.h"
#include "services/webnn/public/mojom/webnn_context_provider.mojom.h"
#include "services/webnn/public/mojom/webnn_error.mojom.h"
#include "services/webnn/public/mojom/webnn_graph_builder.mojom.h"
#include "services/webnn/webnn_buffer_impl.h"
#include "services/webnn/webnn_context_provider_impl.h"
#include "services/webnn/webnn_graph_builder_impl.h"
#include "services/webnn/webnn_graph_impl.h"
namespace webnn {
WebNNContextImpl::WebNNContextImpl(
mojo::PendingReceiver<mojom::WebNNContext> receiver,
WebNNContextProviderImpl* context_provider,
ContextProperties properties,
mojom::CreateContextOptionsPtr options)
: … { … }
WebNNContextImpl::~WebNNContextImpl() = default;
void WebNNContextImpl::OnConnectionError() { … }
#if DCHECK_IS_ON()
void WebNNContextImpl::AssertCalledOnValidSequence() const { … }
#endif
void WebNNContextImpl::ReportBadGraphBuilderMessage(
const std::string& message,
base::PassKey<WebNNGraphBuilderImpl> pass_key) { … }
void WebNNContextImpl::TakeGraph(
std::unique_ptr<WebNNGraphImpl> graph_impl,
mojo::PendingAssociatedReceiver<mojom::WebNNGraph> graph_pending_receiver,
base::PassKey<WebNNGraphBuilderImpl> pass_key) { … }
void WebNNContextImpl::RemoveGraphBuilder(
mojo::ReceiverId graph_builder_id,
base::PassKey<WebNNGraphBuilderImpl> ) { … }
void WebNNContextImpl::CreateGraphBuilder(
mojo::PendingAssociatedReceiver<mojom::WebNNGraphBuilder> receiver) { … }
void WebNNContextImpl::CreateBuffer(
mojom::BufferInfoPtr buffer_info,
mojom::WebNNContext::CreateBufferCallback callback) { … }
void WebNNContextImpl::DidCreateWebNNBufferImpl(
mojom::WebNNContext::CreateBufferCallback callback,
mojo::PendingAssociatedRemote<mojom::WebNNBuffer> remote,
base::expected<std::unique_ptr<WebNNBufferImpl>, mojom::ErrorPtr> result) { … }
void WebNNContextImpl::DisconnectAndDestroyWebNNBufferImpl(
const blink::WebNNBufferToken& handle) { … }
void WebNNContextImpl::OnLost(std::string_view message) { … }
base::optional_ref<WebNNBufferImpl> WebNNContextImpl::GetWebNNBufferImpl(
const blink::WebNNBufferToken& buffer_handle) { … }
ContextProperties WebNNContextImpl::IntersectWithBaseProperties(
ContextProperties backend_context_properties) { … }
}