electron/shell/common/gin_helper/locker.h
Cheng Zhao 3ae3233e65
chore: remove native_mate (Part 12) (#20869)
* refactor: move mate::Event to gin

* refactor: move mate::Locker to gin

* refactor: convert contextBridge to gin

* refactor: convert contentTracing to gin

* refactor: remove callback converter of native_mate

* refactor: remove file_dialog_converter and native_window_converter from native_mate

* refactor: convert webFrame to gin

* refactor: move blink_converter to gin

* refactor: remove net_converter from native_mate

* refactor: remove event_emitter_caller_deprecated

* refactor: remove gurl_converter from native_mate

* refactor: remove file_path and string16_converter from native_mate

* refactor: remove image_converter from native_mate

* refactor: move value_converter to gin
2019-10-31 16:56:00 +09:00

36 lines
962 B
C++

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE.chromium file.
#ifndef SHELL_COMMON_GIN_HELPER_LOCKER_H_
#define SHELL_COMMON_GIN_HELPER_LOCKER_H_
#include <memory>
#include "base/macros.h"
#include "v8/include/v8.h"
namespace gin_helper {
// Only lock when lockers are used in current thread.
class Locker {
public:
explicit Locker(v8::Isolate* isolate);
~Locker();
// Returns whether current process is browser process, currently we detect it
// by checking whether current has used V8 Lock, but it might be a bad idea.
static inline bool IsBrowserProcess() { return v8::Locker::IsActive(); }
private:
void* operator new(size_t size);
void operator delete(void*, size_t);
std::unique_ptr<v8::Locker> locker_;
DISALLOW_COPY_AND_ASSIGN(Locker);
};
} // namespace gin_helper
#endif // SHELL_COMMON_GIN_HELPER_LOCKER_H_