2020-03-19 16:34:15 +01:00
|
|
|
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "include/cef_media_router.h"
|
|
|
|
#include "libcef/browser/browser_context.h"
|
|
|
|
|
2020-10-08 21:54:42 +02:00
|
|
|
#include "components/media_router/common/mojom/media_router.mojom.h"
|
2020-03-19 16:34:15 +01:00
|
|
|
|
|
|
|
class CefRegistrationImpl;
|
|
|
|
|
|
|
|
// Implementation of the CefMediaRouter interface. May be created on any thread.
|
|
|
|
class CefMediaRouterImpl : public CefMediaRouter {
|
|
|
|
public:
|
|
|
|
CefMediaRouterImpl();
|
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
CefMediaRouterImpl(const CefMediaRouterImpl&) = delete;
|
|
|
|
CefMediaRouterImpl& operator=(const CefMediaRouterImpl&) = delete;
|
|
|
|
|
2020-03-19 16:34:15 +01:00
|
|
|
// Called on the UI thread after object creation and before any other object
|
|
|
|
// methods are executed on the UI thread.
|
2021-04-15 01:28:22 +02:00
|
|
|
void Initialize(const CefBrowserContext::Getter& browser_context_getter,
|
|
|
|
CefRefPtr<CefCompletionCallback> callback);
|
2020-03-19 16:34:15 +01:00
|
|
|
|
|
|
|
// CefMediaRouter methods.
|
|
|
|
CefRefPtr<CefRegistration> AddObserver(
|
|
|
|
CefRefPtr<CefMediaObserver> observer) override;
|
|
|
|
CefRefPtr<CefMediaSource> GetSource(const CefString& urn) override;
|
|
|
|
void NotifyCurrentSinks() override;
|
|
|
|
void CreateRoute(CefRefPtr<CefMediaSource> source,
|
|
|
|
CefRefPtr<CefMediaSink> sink,
|
|
|
|
CefRefPtr<CefMediaRouteCreateCallback> callback) override;
|
|
|
|
void NotifyCurrentRoutes() override;
|
|
|
|
|
|
|
|
private:
|
2021-04-15 01:28:22 +02:00
|
|
|
void InitializeRegistrationInternal(
|
2020-03-19 16:34:15 +01:00
|
|
|
CefRefPtr<CefRegistrationImpl> registration);
|
2021-04-15 01:28:22 +02:00
|
|
|
void NotifyCurrentSinksInternal();
|
|
|
|
void CreateRouteInternal(CefRefPtr<CefMediaSource> source,
|
|
|
|
CefRefPtr<CefMediaSink> sink,
|
|
|
|
CefRefPtr<CefMediaRouteCreateCallback> callback);
|
|
|
|
void NotifyCurrentRoutesInternal();
|
2020-03-19 16:34:15 +01:00
|
|
|
|
|
|
|
void CreateRouteCallback(CefRefPtr<CefMediaRouteCreateCallback> callback,
|
|
|
|
const media_router::RouteRequestResult& result);
|
|
|
|
|
2021-04-15 01:28:22 +02:00
|
|
|
// If the context is fully initialized execute |callback|, otherwise
|
|
|
|
// store it until the context is fully initialized.
|
|
|
|
void StoreOrTriggerInitCallback(base::OnceClosure callback);
|
|
|
|
|
|
|
|
bool ValidContext() const;
|
|
|
|
|
2020-03-19 16:34:15 +01:00
|
|
|
// Only accessed on the UI thread. Will be non-null after Initialize().
|
|
|
|
CefBrowserContext::Getter browser_context_getter_;
|
|
|
|
|
2021-04-15 01:28:22 +02:00
|
|
|
bool initialized_ = false;
|
|
|
|
std::vector<base::OnceClosure> init_callbacks_;
|
|
|
|
|
2020-03-19 16:34:15 +01:00
|
|
|
IMPLEMENT_REFCOUNTING(CefMediaRouterImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_
|