// Copyright 2016 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ #define MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_ #include "base/component_export.h" #include "base/threading/thread_restrictions.h" #include "build/build_config.h" #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) #define ENABLE_SYNC_CALL_RESTRICTIONS … #else #define ENABLE_SYNC_CALL_RESTRICTIONS … #endif namespace chromecast { class CastCdmOriginProvider; } // namespace chromecast namespace content { class AndroidOverlaySyncHelper; class DesktopCapturerLacros; class StreamTextureFactory; #if BUILDFLAG(IS_WIN) class DCOMPTextureFactory; #endif } // namespace content namespace crosapi { class ScopedAllowSyncCall; } // namespace crosapi namespace gpu { class CommandBufferProxyImpl; class GpuChannelHost; class SharedImageInterfaceProxy; } // namespace gpu namespace ui { class Compositor; } // namespace ui namespace viz { class GpuHostImpl; class HostFrameSinkManager; class HostGpuMemoryBufferManager; } // namespace viz namespace mojo { class ScopedAllowSyncCallForTesting; // In some processes, sync calls are disallowed. For example, in the browser // process we don't want any sync calls to child processes for performance, // security and stability reasons. SyncCallRestrictions helps to enforce such // rules. // // Before processing a sync call, the bindings call // SyncCallRestrictions::AssertSyncCallAllowed() to check whether sync calls are // allowed. By default sync calls are allowed but they may be globally // disallowed within a process by calling DisallowSyncCall(). // // If globally disallowed but you but you have a very compelling reason to // disregard that (which should be very very rare), you can override it by // constructing a ScopedAllowSyncCall object which allows making sync calls on // the current sequence during its lifetime. class COMPONENT_EXPORT(MOJO_CPP_BINDINGS) SyncCallRestrictions { … }; class ScopedAllowSyncCallForTesting { … }; } // namespace mojo #endif // MOJO_PUBLIC_CPP_BINDINGS_SYNC_CALL_RESTRICTIONS_H_