locker.h 864 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2014 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.chromium file.
  4. #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_LOCKER_H_
  5. #define ELECTRON_SHELL_COMMON_GIN_HELPER_LOCKER_H_
  6. #include <memory>
  7. #include "v8/include/v8.h"
  8. namespace gin_helper {
  9. // Only lock when lockers are used in current thread.
  10. class Locker {
  11. public:
  12. explicit Locker(v8::Isolate* isolate);
  13. ~Locker();
  14. // disable copy
  15. Locker(const Locker&) = delete;
  16. Locker& operator=(const Locker&) = delete;
  17. private:
  18. void* operator new(size_t size);
  19. void operator delete(void*, size_t);
  20. std::unique_ptr<v8::Locker> locker_;
  21. static bool g_is_browser_process;
  22. static bool g_is_renderer_process;
  23. };
  24. } // namespace gin_helper
  25. #endif // ELECTRON_SHELL_COMMON_GIN_HELPER_LOCKER_H_