scoped_allow_sync_call.h 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CHROMEOS_CROSAPI_CPP_SCOPED_ALLOW_SYNC_CALL_H_
  5. #define CHROMEOS_CROSAPI_CPP_SCOPED_ALLOW_SYNC_CALL_H_
  6. #include "base/component_export.h"
  7. #include "mojo/public/cpp/bindings/sync_call_restrictions.h"
  8. class ChromePasswordManagerClient;
  9. namespace crosapi {
  10. // Chrome generally disallows sync IPC calls. Crosapi allows a small number of
  11. // exceptions to support cross-platform code where other platforms all provide a
  12. // synchronous implementation of a particular API. Use this sparingly.
  13. class COMPONENT_EXPORT(CROSAPI) ScopedAllowSyncCall {
  14. private:
  15. // Consumers of this class must be explicitly added as a friend.
  16. friend class ::ChromePasswordManagerClient;
  17. ScopedAllowSyncCall();
  18. ScopedAllowSyncCall(const ScopedAllowSyncCall&) = delete;
  19. ScopedAllowSyncCall& operator=(const ScopedAllowSyncCall&) = delete;
  20. ~ScopedAllowSyncCall();
  21. mojo::SyncCallRestrictions::ScopedAllowSyncCall scoped_allow_;
  22. };
  23. } // namespace crosapi
  24. #endif // CHROMEOS_CROSAPI_CPP_SCOPED_ALLOW_SYNC_CALL_H_