chromium/remoting/base/auto_thread.cc

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

#include "remoting/base/auto_thread.h"

#include <memory>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_executor.h"
#include "base/threading/thread_local.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "third_party/abseil-cpp/absl/base/dynamic_annotations.h"

#if BUILDFLAG(IS_POSIX)
#include "base/files/file_descriptor_watcher_posix.h"
#endif

#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_com_initializer.h"
#endif

namespace remoting {

namespace {

#if BUILDFLAG(IS_WIN)
std::unique_ptr<base::win::ScopedCOMInitializer> CreateComInitializer(
    AutoThread::ComInitType type) {
  std::unique_ptr<base::win::ScopedCOMInitializer> initializer;
  if (type == AutoThread::COM_INIT_MTA) {
    initializer = std::make_unique<base::win::ScopedCOMInitializer>(
        base::win::ScopedCOMInitializer::kMTA);
  } else if (type == AutoThread::COM_INIT_STA) {
    initializer = std::make_unique<base::win::ScopedCOMInitializer>();
  }
  return initializer;
}
#endif

}  // namespace

// Used to pass data to ThreadMain.  This structure is allocated on the stack
// from within StartWithType.
struct AutoThread::StartupData {};

// static
scoped_refptr<AutoThreadTaskRunner> AutoThread::CreateWithType(
    const char* name,
    scoped_refptr<AutoThreadTaskRunner> joiner,
    base::MessagePumpType type) {}

// static
scoped_refptr<AutoThreadTaskRunner> AutoThread::Create(
    const char* name,
    scoped_refptr<AutoThreadTaskRunner> joiner) {}

#if BUILDFLAG(IS_WIN)
// static
scoped_refptr<AutoThreadTaskRunner> AutoThread::CreateWithLoopAndComInitTypes(
    const char* name,
    scoped_refptr<AutoThreadTaskRunner> joiner,
    base::MessagePumpType pump_type,
    ComInitType com_init_type) {
  AutoThread* thread = new AutoThread(name, joiner.get());
  thread->SetComInitType(com_init_type);
  scoped_refptr<AutoThreadTaskRunner> task_runner =
      thread->StartWithType(pump_type);
  if (!task_runner.get()) {
    delete thread;
  }
  return task_runner;
}
#endif

AutoThread::AutoThread(const char* name)
    :{}

AutoThread::AutoThread(const char* name, AutoThreadTaskRunner* joiner)
    :{}

AutoThread::~AutoThread() {}

scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType(
    base::MessagePumpType type) {}

#if BUILDFLAG(IS_WIN)
void AutoThread::SetComInitType(ComInitType com_init_type) {
  DCHECK_EQ(com_init_type_, COM_INIT_NONE);
  com_init_type_ = com_init_type;
}
#endif

void AutoThread::QuitThread(base::OnceClosure quit_when_idle_closure) {}

void AutoThread::JoinAndDeleteThread() {}

void AutoThread::ThreadMain() {}

}  // namespace remoting