chromium/mojo/core/embedder/embedder.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/core/embedder/embedder.h"

#include <stdint.h>

#include <optional>
#include <string>
#include <utility>

#include "base/check.h"
#include "base/feature_list.h"
#include "base/memory/ref_counted.h"
#include "base/notreached.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_runner.h"
#include "build/build_config.h"
#include "mojo/buildflags.h"
#include "mojo/core/channel.h"
#include "mojo/core/configuration.h"
#include "mojo/core/core_ipcz.h"
#include "mojo/core/embedder/features.h"
#include "mojo/core/ipcz_api.h"
#include "mojo/core/ipcz_driver/base_shared_memory_service.h"
#include "mojo/core/ipcz_driver/driver.h"
#include "mojo/core/ipcz_driver/transport.h"
#include "mojo/public/c/system/thunks.h"

#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
#include <atomic>

#include "base/environment.h"
#include "mojo/core/core.h"
#include "mojo/core/entrypoints.h"
#include "mojo/core/node_controller.h"
#endif

#if !BUILDFLAG(IS_NACL)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
#include "mojo/core/channel_linux.h"
#endif  // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
        // BUILDFLAG(IS_ANDROID)
#endif  // !BUILDFLAG(IS_NACL)

namespace mojo::core {

namespace {

#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
#if BUILDFLAG(IS_CHROMEOS) && !defined(ENABLE_IPCZ_ON_CHROMEOS)
std::atomic<bool> g_mojo_ipcz_enabled{false};
#elif !BUILDFLAG(IS_ANDROID)
// Default to enabled even if InitFeatures() is never called.
std::atomic<bool> g_mojo_ipcz_enabled{true};
#endif

bool g_mojo_ipcz_force_disabled = false;

std::optional<std::string> GetMojoIpczEnvVar() {
  std::string value;
  auto env = base::Environment::Create();
  if (!env->GetVar("MOJO_IPCZ", &value)) {
    return std::nullopt;
  }
  return value;
}

// Allows MojoIpcz to be forcibly enabled if and only if MOJO_IPCZ=1 in the
// environment. Note that any other value (or absence) has no influence on
// whether or not MojoIpcz is enabled.
bool IsMojoIpczForceEnabledByEnvironment() {
  static bool force_enabled = GetMojoIpczEnvVar() == "1";
  return force_enabled;
}
#endif  // BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)

bool g_enable_memv2 =;

}  // namespace

// InitFeatures will be called as soon as the base::FeatureList is initialized.
void InitFeatures() {}

void EnableMojoIpcz() {}

void Init(const Configuration& configuration) {}

void Init() {}

void ShutDown() {}

scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() {}

bool IsMojoIpczEnabled() {}

void InstallMojoIpczBaseSharedMemoryHooks() {}

const IpczAPI& GetIpczAPIForMojo() {}

const IpczDriver& GetIpczDriverForMojo() {}

IpczDriverHandle CreateIpczTransportFromEndpoint(
    mojo::PlatformChannelEndpoint endpoint,
    const TransportEndpointTypes& endpoint_types,
    base::Process remote_process) {}

}  // namespace mojo::core