Wait for CefBrowserContext initialization (see issue #2969)

With the Chrome runtime, Profile initialization may be asynchronous. Code that
waited on CefBrowserContext creation now needs to wait on CefBrowserContext
initialization instead.
This commit is contained in:
Marshall Greenblatt
2021-04-14 19:28:22 -04:00
parent fc7f9ff505
commit 34c63a665d
39 changed files with 779 additions and 477 deletions

View File

@@ -20,7 +20,8 @@ class CefMediaRouterImpl : public CefMediaRouter {
// Called on the UI thread after object creation and before any other object
// methods are executed on the UI thread.
void Initialize(const CefBrowserContext::Getter& browser_context_getter);
void Initialize(const CefBrowserContext::Getter& browser_context_getter,
CefRefPtr<CefCompletionCallback> callback);
// CefMediaRouter methods.
CefRefPtr<CefRegistration> AddObserver(
@@ -33,15 +34,29 @@ class CefMediaRouterImpl : public CefMediaRouter {
void NotifyCurrentRoutes() override;
private:
void InitializeRegistrationOnUIThread(
void InitializeRegistrationInternal(
CefRefPtr<CefRegistrationImpl> registration);
void NotifyCurrentSinksInternal();
void CreateRouteInternal(CefRefPtr<CefMediaSource> source,
CefRefPtr<CefMediaSink> sink,
CefRefPtr<CefMediaRouteCreateCallback> callback);
void NotifyCurrentRoutesInternal();
void CreateRouteCallback(CefRefPtr<CefMediaRouteCreateCallback> callback,
const media_router::RouteRequestResult& result);
// 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;
// Only accessed on the UI thread. Will be non-null after Initialize().
CefBrowserContext::Getter browser_context_getter_;
bool initialized_ = false;
std::vector<base::OnceClosure> init_callbacks_;
IMPLEMENT_REFCOUNTING(CefMediaRouterImpl);
DISALLOW_COPY_AND_ASSIGN(CefMediaRouterImpl);
};