
Automated patch, intended to be effectively a no-op. Context: https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email&utm_source=footer As of https://crrev.com/1204351, absl::optional is now a type alias for std::optional. We should migrate toward it. Script: ``` function replace { echo "Replacing $1 by $2" git grep -l "$1" \ | cut -f1 -d: \ | grep \ -e "^content" \ | sort \ | uniq \ | grep \ -e "\.h" \ -e "\.cc" \ -e "\.mm" \ -e "\.py" \ | xargs sed -i "s/$1/$2/g" } replace "absl::make_optional" "std::make_optional" replace "absl::optional" "std::optional" replace "absl::nullopt" "std::nullopt" replace "absl::in_place" "std::in_place" replace "absl::in_place_t" "std::in_place_t" replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>" git cl format ``` # Skipping unrelated "check_network_annotation" errors. NOTRY=True Bug: chromium:1500249 Change-Id: Icfd31a71d8faf63a2e8d5401127e7ee74cc1c413 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5185537 Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org> Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Owners-Override: Avi Drissman <avi@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/main@{#1245739}
82 lines
3.0 KiB
C++
82 lines
3.0 KiB
C++
// 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.
|
|
|
|
#ifndef CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
|
|
#define CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
|
|
|
|
#include "base/memory/scoped_refptr.h"
|
|
#include "base/task/single_thread_task_runner.h"
|
|
#include "build/build_config.h"
|
|
#include "content/common/content_export.h"
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
|
#if BUILDFLAG(IS_POSIX)
|
|
#include <optional>
|
|
|
|
#include "base/files/file_descriptor_watcher_posix.h"
|
|
#endif
|
|
|
|
namespace content {
|
|
|
|
class BrowserMainLoop;
|
|
class BrowserProcessIOThread;
|
|
class TestBrowserThread;
|
|
|
|
// BrowserThreadImpl is a scoped object which maps a SingleThreadTaskRunner to a
|
|
// BrowserThread::ID. On ~BrowserThreadImpl() that ID enters a SHUTDOWN state
|
|
// (in which BrowserThread::IsThreadInitialized() returns false) but the mapping
|
|
// isn't undone to avoid shutdown races (the task runner is free to stop
|
|
// accepting tasks by then however).
|
|
//
|
|
// Very few users should use this directly. To mock BrowserThreads, tests should
|
|
// use BrowserTaskEnvironment instead.
|
|
class CONTENT_EXPORT BrowserThreadImpl : public BrowserThread {
|
|
public:
|
|
~BrowserThreadImpl();
|
|
|
|
// Returns the thread name for |identifier|.
|
|
static const char* GetThreadName(BrowserThread::ID identifier);
|
|
|
|
// Resets globals for |identifier|. Used in tests to clear global state that
|
|
// would otherwise leak to the next test. Globals are not otherwise fully
|
|
// cleaned up in ~BrowserThreadImpl() as there are subtle differences between
|
|
// UNINITIALIZED and SHUTDOWN state (e.g. globals.task_runners are kept around
|
|
// on shutdown). Must be called after ~BrowserThreadImpl() for the given
|
|
// |identifier|.
|
|
static void ResetGlobalsForTesting(BrowserThread::ID identifier);
|
|
|
|
// Exposed for BrowserTaskExecutor. Other code should use
|
|
// GetUIThreadTaskRunner({/IO}).
|
|
using BrowserThread::GetTaskRunnerForThread;
|
|
|
|
private:
|
|
// Restrict instantiation to BrowserProcessIOThread as it performs important
|
|
// initialization that shouldn't be bypassed (except by BrowserMainLoop for
|
|
// the main thread).
|
|
friend class BrowserProcessIOThread;
|
|
friend class BrowserMainLoop;
|
|
// TestBrowserThread is also allowed to construct this when instantiating fake
|
|
// threads.
|
|
friend class TestBrowserThread;
|
|
|
|
// Binds |identifier| to |task_runner| for the browser_thread.h API. This
|
|
// needs to happen on the main thread before //content and embedders are
|
|
// kicked off and enabled to invoke the BrowserThread API from other threads.
|
|
BrowserThreadImpl(BrowserThread::ID identifier,
|
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
|
|
|
|
// The identifier of this thread. Only one thread can exist with a given
|
|
// identifier at a given time.
|
|
ID identifier_;
|
|
|
|
#if BUILDFLAG(IS_POSIX)
|
|
// Allows usage of the FileDescriptorWatcher API on the UI thread.
|
|
std::optional<base::FileDescriptorWatcher> file_descriptor_watcher_;
|
|
#endif
|
|
};
|
|
|
|
} // namespace content
|
|
|
|
#endif // CONTENT_BROWSER_BROWSER_THREAD_IMPL_H_
|