xref: /aosp_15_r20/external/cronet/base/task/current_thread.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker // Copyright 2018 The Chromium Authors
2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file.
4*6777b538SAndroid Build Coastguard Worker 
5*6777b538SAndroid Build Coastguard Worker #include "base/task/current_thread.h"
6*6777b538SAndroid Build Coastguard Worker 
7*6777b538SAndroid Build Coastguard Worker #include <utility>
8*6777b538SAndroid Build Coastguard Worker 
9*6777b538SAndroid Build Coastguard Worker #include "base/callback_list.h"
10*6777b538SAndroid Build Coastguard Worker #include "base/functional/bind.h"
11*6777b538SAndroid Build Coastguard Worker #include "base/functional/callback.h"
12*6777b538SAndroid Build Coastguard Worker #include "base/message_loop/message_pump_for_io.h"
13*6777b538SAndroid Build Coastguard Worker #include "base/message_loop/message_pump_for_ui.h"
14*6777b538SAndroid Build Coastguard Worker #include "base/message_loop/message_pump_type.h"
15*6777b538SAndroid Build Coastguard Worker #include "base/task/sequence_manager/sequence_manager_impl.h"
16*6777b538SAndroid Build Coastguard Worker #include "base/threading/thread_local.h"
17*6777b538SAndroid Build Coastguard Worker #include "base/trace_event/base_tracing.h"
18*6777b538SAndroid Build Coastguard Worker #include "build/build_config.h"
19*6777b538SAndroid Build Coastguard Worker 
20*6777b538SAndroid Build Coastguard Worker namespace base {
21*6777b538SAndroid Build Coastguard Worker 
22*6777b538SAndroid Build Coastguard Worker //------------------------------------------------------------------------------
23*6777b538SAndroid Build Coastguard Worker // CurrentThread
24*6777b538SAndroid Build Coastguard Worker 
25*6777b538SAndroid Build Coastguard Worker // static
26*6777b538SAndroid Build Coastguard Worker sequence_manager::internal::SequenceManagerImpl*
GetCurrentSequenceManagerImpl()27*6777b538SAndroid Build Coastguard Worker CurrentThread::GetCurrentSequenceManagerImpl() {
28*6777b538SAndroid Build Coastguard Worker   return sequence_manager::internal::SequenceManagerImpl::GetCurrent();
29*6777b538SAndroid Build Coastguard Worker }
30*6777b538SAndroid Build Coastguard Worker 
31*6777b538SAndroid Build Coastguard Worker // static
Get()32*6777b538SAndroid Build Coastguard Worker CurrentThread CurrentThread::Get() {
33*6777b538SAndroid Build Coastguard Worker   return CurrentThread(GetCurrentSequenceManagerImpl());
34*6777b538SAndroid Build Coastguard Worker }
35*6777b538SAndroid Build Coastguard Worker 
36*6777b538SAndroid Build Coastguard Worker // static
GetNull()37*6777b538SAndroid Build Coastguard Worker CurrentThread CurrentThread::GetNull() {
38*6777b538SAndroid Build Coastguard Worker   return CurrentThread(nullptr);
39*6777b538SAndroid Build Coastguard Worker }
40*6777b538SAndroid Build Coastguard Worker 
41*6777b538SAndroid Build Coastguard Worker // static
IsSet()42*6777b538SAndroid Build Coastguard Worker bool CurrentThread::IsSet() {
43*6777b538SAndroid Build Coastguard Worker   return !!GetCurrentSequenceManagerImpl();
44*6777b538SAndroid Build Coastguard Worker }
45*6777b538SAndroid Build Coastguard Worker 
AddDestructionObserver(DestructionObserver * destruction_observer)46*6777b538SAndroid Build Coastguard Worker void CurrentThread::AddDestructionObserver(
47*6777b538SAndroid Build Coastguard Worker     DestructionObserver* destruction_observer) {
48*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
49*6777b538SAndroid Build Coastguard Worker   current_->AddDestructionObserver(destruction_observer);
50*6777b538SAndroid Build Coastguard Worker }
51*6777b538SAndroid Build Coastguard Worker 
RemoveDestructionObserver(DestructionObserver * destruction_observer)52*6777b538SAndroid Build Coastguard Worker void CurrentThread::RemoveDestructionObserver(
53*6777b538SAndroid Build Coastguard Worker     DestructionObserver* destruction_observer) {
54*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
55*6777b538SAndroid Build Coastguard Worker   current_->RemoveDestructionObserver(destruction_observer);
56*6777b538SAndroid Build Coastguard Worker }
57*6777b538SAndroid Build Coastguard Worker 
SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner)58*6777b538SAndroid Build Coastguard Worker void CurrentThread::SetTaskRunner(
59*6777b538SAndroid Build Coastguard Worker     scoped_refptr<SingleThreadTaskRunner> task_runner) {
60*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
61*6777b538SAndroid Build Coastguard Worker   current_->SetTaskRunner(std::move(task_runner));
62*6777b538SAndroid Build Coastguard Worker }
63*6777b538SAndroid Build Coastguard Worker 
IsBoundToCurrentThread() const64*6777b538SAndroid Build Coastguard Worker bool CurrentThread::IsBoundToCurrentThread() const {
65*6777b538SAndroid Build Coastguard Worker   return current_ == GetCurrentSequenceManagerImpl();
66*6777b538SAndroid Build Coastguard Worker }
67*6777b538SAndroid Build Coastguard Worker 
IsIdleForTesting()68*6777b538SAndroid Build Coastguard Worker bool CurrentThread::IsIdleForTesting() {
69*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
70*6777b538SAndroid Build Coastguard Worker   return current_->IsIdleForTesting();
71*6777b538SAndroid Build Coastguard Worker }
72*6777b538SAndroid Build Coastguard Worker 
EnableMessagePumpTimeKeeperMetrics(const char * thread_name)73*6777b538SAndroid Build Coastguard Worker void CurrentThread::EnableMessagePumpTimeKeeperMetrics(
74*6777b538SAndroid Build Coastguard Worker     const char* thread_name) {
75*6777b538SAndroid Build Coastguard Worker   return current_->EnableMessagePumpTimeKeeperMetrics(thread_name);
76*6777b538SAndroid Build Coastguard Worker }
77*6777b538SAndroid Build Coastguard Worker 
AddTaskObserver(TaskObserver * task_observer)78*6777b538SAndroid Build Coastguard Worker void CurrentThread::AddTaskObserver(TaskObserver* task_observer) {
79*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
80*6777b538SAndroid Build Coastguard Worker   current_->AddTaskObserver(task_observer);
81*6777b538SAndroid Build Coastguard Worker }
82*6777b538SAndroid Build Coastguard Worker 
RemoveTaskObserver(TaskObserver * task_observer)83*6777b538SAndroid Build Coastguard Worker void CurrentThread::RemoveTaskObserver(TaskObserver* task_observer) {
84*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
85*6777b538SAndroid Build Coastguard Worker   current_->RemoveTaskObserver(task_observer);
86*6777b538SAndroid Build Coastguard Worker }
87*6777b538SAndroid Build Coastguard Worker 
SetAddQueueTimeToTasks(bool enable)88*6777b538SAndroid Build Coastguard Worker void CurrentThread::SetAddQueueTimeToTasks(bool enable) {
89*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
90*6777b538SAndroid Build Coastguard Worker   current_->SetAddQueueTimeToTasks(enable);
91*6777b538SAndroid Build Coastguard Worker }
92*6777b538SAndroid Build Coastguard Worker 
RegisterOnNextIdleCallback(RegisterOnNextIdleCallbackPasskey,OnceClosure on_next_idle_callback)93*6777b538SAndroid Build Coastguard Worker CallbackListSubscription CurrentThread::RegisterOnNextIdleCallback(
94*6777b538SAndroid Build Coastguard Worker     RegisterOnNextIdleCallbackPasskey,
95*6777b538SAndroid Build Coastguard Worker     OnceClosure on_next_idle_callback) {
96*6777b538SAndroid Build Coastguard Worker   return current_->RegisterOnNextIdleCallback(std::move(on_next_idle_callback));
97*6777b538SAndroid Build Coastguard Worker }
98*6777b538SAndroid Build Coastguard Worker 
99*6777b538SAndroid Build Coastguard Worker CurrentThread::ScopedAllowApplicationTasksInNativeNestedLoop::
ScopedAllowApplicationTasksInNativeNestedLoop()100*6777b538SAndroid Build Coastguard Worker     ScopedAllowApplicationTasksInNativeNestedLoop()
101*6777b538SAndroid Build Coastguard Worker     : sequence_manager_(GetCurrentSequenceManagerImpl()),
102*6777b538SAndroid Build Coastguard Worker       previous_state_(
103*6777b538SAndroid Build Coastguard Worker           sequence_manager_->IsTaskExecutionAllowedInNativeNestedLoop()) {
104*6777b538SAndroid Build Coastguard Worker   TRACE_EVENT_BEGIN0("base", "ScopedNestableTaskAllower");
105*6777b538SAndroid Build Coastguard Worker   sequence_manager_->SetTaskExecutionAllowedInNativeNestedLoop(true);
106*6777b538SAndroid Build Coastguard Worker }
107*6777b538SAndroid Build Coastguard Worker 
108*6777b538SAndroid Build Coastguard Worker CurrentThread::ScopedAllowApplicationTasksInNativeNestedLoop::
~ScopedAllowApplicationTasksInNativeNestedLoop()109*6777b538SAndroid Build Coastguard Worker     ~ScopedAllowApplicationTasksInNativeNestedLoop() {
110*6777b538SAndroid Build Coastguard Worker   sequence_manager_->SetTaskExecutionAllowedInNativeNestedLoop(previous_state_);
111*6777b538SAndroid Build Coastguard Worker   TRACE_EVENT_END0("base", "ScopedNestableTaskAllower");
112*6777b538SAndroid Build Coastguard Worker }
113*6777b538SAndroid Build Coastguard Worker 
ApplicationTasksAllowedInNativeNestedLoop() const114*6777b538SAndroid Build Coastguard Worker bool CurrentThread::ApplicationTasksAllowedInNativeNestedLoop() const {
115*6777b538SAndroid Build Coastguard Worker   return current_->IsTaskExecutionAllowedInNativeNestedLoop();
116*6777b538SAndroid Build Coastguard Worker }
117*6777b538SAndroid Build Coastguard Worker 
118*6777b538SAndroid Build Coastguard Worker #if !BUILDFLAG(IS_NACL)
119*6777b538SAndroid Build Coastguard Worker 
120*6777b538SAndroid Build Coastguard Worker //------------------------------------------------------------------------------
121*6777b538SAndroid Build Coastguard Worker // CurrentUIThread
122*6777b538SAndroid Build Coastguard Worker 
123*6777b538SAndroid Build Coastguard Worker // static
Get()124*6777b538SAndroid Build Coastguard Worker CurrentUIThread CurrentUIThread::Get() {
125*6777b538SAndroid Build Coastguard Worker   auto* sequence_manager = GetCurrentSequenceManagerImpl();
126*6777b538SAndroid Build Coastguard Worker   DCHECK(sequence_manager);
127*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_ANDROID)
128*6777b538SAndroid Build Coastguard Worker   DCHECK(sequence_manager->IsType(MessagePumpType::UI) ||
129*6777b538SAndroid Build Coastguard Worker          sequence_manager->IsType(MessagePumpType::JAVA));
130*6777b538SAndroid Build Coastguard Worker #else   // BUILDFLAG(IS_ANDROID)
131*6777b538SAndroid Build Coastguard Worker   DCHECK(sequence_manager->IsType(MessagePumpType::UI));
132*6777b538SAndroid Build Coastguard Worker #endif  // BUILDFLAG(IS_ANDROID)
133*6777b538SAndroid Build Coastguard Worker   return CurrentUIThread(sequence_manager);
134*6777b538SAndroid Build Coastguard Worker }
135*6777b538SAndroid Build Coastguard Worker 
136*6777b538SAndroid Build Coastguard Worker // static
IsSet()137*6777b538SAndroid Build Coastguard Worker bool CurrentUIThread::IsSet() {
138*6777b538SAndroid Build Coastguard Worker   sequence_manager::internal::SequenceManagerImpl* sequence_manager =
139*6777b538SAndroid Build Coastguard Worker       GetCurrentSequenceManagerImpl();
140*6777b538SAndroid Build Coastguard Worker   return sequence_manager &&
141*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_ANDROID)
142*6777b538SAndroid Build Coastguard Worker          (sequence_manager->IsType(MessagePumpType::UI) ||
143*6777b538SAndroid Build Coastguard Worker           sequence_manager->IsType(MessagePumpType::JAVA));
144*6777b538SAndroid Build Coastguard Worker #else   // BUILDFLAG(IS_ANDROID)
145*6777b538SAndroid Build Coastguard Worker          sequence_manager->IsType(MessagePumpType::UI);
146*6777b538SAndroid Build Coastguard Worker #endif  // BUILDFLAG(IS_ANDROID)
147*6777b538SAndroid Build Coastguard Worker }
148*6777b538SAndroid Build Coastguard Worker 
GetMessagePumpForUI() const149*6777b538SAndroid Build Coastguard Worker MessagePumpForUI* CurrentUIThread::GetMessagePumpForUI() const {
150*6777b538SAndroid Build Coastguard Worker   return static_cast<MessagePumpForUI*>(current_->GetMessagePump());
151*6777b538SAndroid Build Coastguard Worker }
152*6777b538SAndroid Build Coastguard Worker 
153*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_OZONE) && !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_WIN)
WatchFileDescriptor(int fd,bool persistent,MessagePumpForUI::Mode mode,MessagePumpForUI::FdWatchController * controller,MessagePumpForUI::FdWatcher * delegate)154*6777b538SAndroid Build Coastguard Worker bool CurrentUIThread::WatchFileDescriptor(
155*6777b538SAndroid Build Coastguard Worker     int fd,
156*6777b538SAndroid Build Coastguard Worker     bool persistent,
157*6777b538SAndroid Build Coastguard Worker     MessagePumpForUI::Mode mode,
158*6777b538SAndroid Build Coastguard Worker     MessagePumpForUI::FdWatchController* controller,
159*6777b538SAndroid Build Coastguard Worker     MessagePumpForUI::FdWatcher* delegate) {
160*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
161*6777b538SAndroid Build Coastguard Worker   return GetMessagePumpForUI()->WatchFileDescriptor(fd, persistent, mode,
162*6777b538SAndroid Build Coastguard Worker                                                     controller, delegate);
163*6777b538SAndroid Build Coastguard Worker }
164*6777b538SAndroid Build Coastguard Worker #endif
165*6777b538SAndroid Build Coastguard Worker 
166*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_IOS)
Attach()167*6777b538SAndroid Build Coastguard Worker void CurrentUIThread::Attach() {
168*6777b538SAndroid Build Coastguard Worker   current_->AttachToMessagePump();
169*6777b538SAndroid Build Coastguard Worker }
170*6777b538SAndroid Build Coastguard Worker #endif  // BUILDFLAG(IS_IOS)
171*6777b538SAndroid Build Coastguard Worker 
172*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_ANDROID)
Abort()173*6777b538SAndroid Build Coastguard Worker void CurrentUIThread::Abort() {
174*6777b538SAndroid Build Coastguard Worker   GetMessagePumpForUI()->Abort();
175*6777b538SAndroid Build Coastguard Worker }
176*6777b538SAndroid Build Coastguard Worker #endif  // BUILDFLAG(IS_ANDROID)
177*6777b538SAndroid Build Coastguard Worker 
178*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_WIN)
AddMessagePumpObserver(MessagePumpForUI::Observer * observer)179*6777b538SAndroid Build Coastguard Worker void CurrentUIThread::AddMessagePumpObserver(
180*6777b538SAndroid Build Coastguard Worker     MessagePumpForUI::Observer* observer) {
181*6777b538SAndroid Build Coastguard Worker   GetMessagePumpForUI()->AddObserver(observer);
182*6777b538SAndroid Build Coastguard Worker }
183*6777b538SAndroid Build Coastguard Worker 
RemoveMessagePumpObserver(MessagePumpForUI::Observer * observer)184*6777b538SAndroid Build Coastguard Worker void CurrentUIThread::RemoveMessagePumpObserver(
185*6777b538SAndroid Build Coastguard Worker     MessagePumpForUI::Observer* observer) {
186*6777b538SAndroid Build Coastguard Worker   GetMessagePumpForUI()->RemoveObserver(observer);
187*6777b538SAndroid Build Coastguard Worker }
188*6777b538SAndroid Build Coastguard Worker #endif  // BUILDFLAG(IS_WIN)
189*6777b538SAndroid Build Coastguard Worker 
190*6777b538SAndroid Build Coastguard Worker #endif  // !BUILDFLAG(IS_NACL)
191*6777b538SAndroid Build Coastguard Worker 
192*6777b538SAndroid Build Coastguard Worker //------------------------------------------------------------------------------
193*6777b538SAndroid Build Coastguard Worker // CurrentIOThread
194*6777b538SAndroid Build Coastguard Worker 
195*6777b538SAndroid Build Coastguard Worker // static
Get()196*6777b538SAndroid Build Coastguard Worker CurrentIOThread CurrentIOThread::Get() {
197*6777b538SAndroid Build Coastguard Worker   auto* sequence_manager = GetCurrentSequenceManagerImpl();
198*6777b538SAndroid Build Coastguard Worker   DCHECK(sequence_manager);
199*6777b538SAndroid Build Coastguard Worker   DCHECK(sequence_manager->IsType(MessagePumpType::IO));
200*6777b538SAndroid Build Coastguard Worker   return CurrentIOThread(sequence_manager);
201*6777b538SAndroid Build Coastguard Worker }
202*6777b538SAndroid Build Coastguard Worker 
203*6777b538SAndroid Build Coastguard Worker // static
IsSet()204*6777b538SAndroid Build Coastguard Worker bool CurrentIOThread::IsSet() {
205*6777b538SAndroid Build Coastguard Worker   auto* sequence_manager = GetCurrentSequenceManagerImpl();
206*6777b538SAndroid Build Coastguard Worker   return sequence_manager && sequence_manager->IsType(MessagePumpType::IO);
207*6777b538SAndroid Build Coastguard Worker }
208*6777b538SAndroid Build Coastguard Worker 
GetMessagePumpForIO() const209*6777b538SAndroid Build Coastguard Worker MessagePumpForIO* CurrentIOThread::GetMessagePumpForIO() const {
210*6777b538SAndroid Build Coastguard Worker   return static_cast<MessagePumpForIO*>(current_->GetMessagePump());
211*6777b538SAndroid Build Coastguard Worker }
212*6777b538SAndroid Build Coastguard Worker 
213*6777b538SAndroid Build Coastguard Worker #if !BUILDFLAG(IS_NACL)
214*6777b538SAndroid Build Coastguard Worker 
215*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_WIN)
RegisterIOHandler(HANDLE file,MessagePumpForIO::IOHandler * handler)216*6777b538SAndroid Build Coastguard Worker HRESULT CurrentIOThread::RegisterIOHandler(
217*6777b538SAndroid Build Coastguard Worker     HANDLE file,
218*6777b538SAndroid Build Coastguard Worker     MessagePumpForIO::IOHandler* handler) {
219*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
220*6777b538SAndroid Build Coastguard Worker   return GetMessagePumpForIO()->RegisterIOHandler(file, handler);
221*6777b538SAndroid Build Coastguard Worker }
222*6777b538SAndroid Build Coastguard Worker 
RegisterJobObject(HANDLE job,MessagePumpForIO::IOHandler * handler)223*6777b538SAndroid Build Coastguard Worker bool CurrentIOThread::RegisterJobObject(HANDLE job,
224*6777b538SAndroid Build Coastguard Worker                                         MessagePumpForIO::IOHandler* handler) {
225*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
226*6777b538SAndroid Build Coastguard Worker   return GetMessagePumpForIO()->RegisterJobObject(job, handler);
227*6777b538SAndroid Build Coastguard Worker }
228*6777b538SAndroid Build Coastguard Worker 
229*6777b538SAndroid Build Coastguard Worker #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
WatchFileDescriptor(int fd,bool persistent,MessagePumpForIO::Mode mode,MessagePumpForIO::FdWatchController * controller,MessagePumpForIO::FdWatcher * delegate)230*6777b538SAndroid Build Coastguard Worker bool CurrentIOThread::WatchFileDescriptor(
231*6777b538SAndroid Build Coastguard Worker     int fd,
232*6777b538SAndroid Build Coastguard Worker     bool persistent,
233*6777b538SAndroid Build Coastguard Worker     MessagePumpForIO::Mode mode,
234*6777b538SAndroid Build Coastguard Worker     MessagePumpForIO::FdWatchController* controller,
235*6777b538SAndroid Build Coastguard Worker     MessagePumpForIO::FdWatcher* delegate) {
236*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
237*6777b538SAndroid Build Coastguard Worker   return GetMessagePumpForIO()->WatchFileDescriptor(fd, persistent, mode,
238*6777b538SAndroid Build Coastguard Worker                                                     controller, delegate);
239*6777b538SAndroid Build Coastguard Worker }
240*6777b538SAndroid Build Coastguard Worker #endif  // BUILDFLAG(IS_WIN)
241*6777b538SAndroid Build Coastguard Worker 
242*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_MAC) || (BUILDFLAG(IS_IOS) && !BUILDFLAG(CRONET_BUILD))
WatchMachReceivePort(mach_port_t port,MessagePumpForIO::MachPortWatchController * controller,MessagePumpForIO::MachPortWatcher * delegate)243*6777b538SAndroid Build Coastguard Worker bool CurrentIOThread::WatchMachReceivePort(
244*6777b538SAndroid Build Coastguard Worker     mach_port_t port,
245*6777b538SAndroid Build Coastguard Worker     MessagePumpForIO::MachPortWatchController* controller,
246*6777b538SAndroid Build Coastguard Worker     MessagePumpForIO::MachPortWatcher* delegate) {
247*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
248*6777b538SAndroid Build Coastguard Worker   return GetMessagePumpForIO()->WatchMachReceivePort(port, controller,
249*6777b538SAndroid Build Coastguard Worker                                                      delegate);
250*6777b538SAndroid Build Coastguard Worker }
251*6777b538SAndroid Build Coastguard Worker #endif
252*6777b538SAndroid Build Coastguard Worker 
253*6777b538SAndroid Build Coastguard Worker #endif  // !BUILDFLAG(IS_NACL)
254*6777b538SAndroid Build Coastguard Worker 
255*6777b538SAndroid Build Coastguard Worker #if BUILDFLAG(IS_FUCHSIA)
256*6777b538SAndroid Build Coastguard Worker // Additional watch API for native platform resources.
WatchZxHandle(zx_handle_t handle,bool persistent,zx_signals_t signals,MessagePumpForIO::ZxHandleWatchController * controller,MessagePumpForIO::ZxHandleWatcher * delegate)257*6777b538SAndroid Build Coastguard Worker bool CurrentIOThread::WatchZxHandle(
258*6777b538SAndroid Build Coastguard Worker     zx_handle_t handle,
259*6777b538SAndroid Build Coastguard Worker     bool persistent,
260*6777b538SAndroid Build Coastguard Worker     zx_signals_t signals,
261*6777b538SAndroid Build Coastguard Worker     MessagePumpForIO::ZxHandleWatchController* controller,
262*6777b538SAndroid Build Coastguard Worker     MessagePumpForIO::ZxHandleWatcher* delegate) {
263*6777b538SAndroid Build Coastguard Worker   DCHECK(current_->IsBoundToCurrentThread());
264*6777b538SAndroid Build Coastguard Worker   return GetMessagePumpForIO()->WatchZxHandle(handle, persistent, signals,
265*6777b538SAndroid Build Coastguard Worker                                               controller, delegate);
266*6777b538SAndroid Build Coastguard Worker }
267*6777b538SAndroid Build Coastguard Worker #endif
268*6777b538SAndroid Build Coastguard Worker 
269*6777b538SAndroid Build Coastguard Worker }  // namespace base
270