electron/shell/common/gin_helper/microtasks_scope.cc
Charles Kerr 2844e346b9
refactor: use std::optional in MicrotasksScope (#43621)
avoid an unnecessary heap allocation/free
2024-09-09 12:51:42 -04:00

25 lines
812 B
C++

// Copyright (c) 2020 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/gin_helper/microtasks_scope.h"
#include "shell/common/process_util.h"
namespace gin_helper {
MicrotasksScope::MicrotasksScope(v8::Isolate* isolate,
v8::MicrotaskQueue* microtask_queue,
bool ignore_browser_checkpoint,
v8::MicrotasksScope::Type scope_type) {
if (electron::IsBrowserProcess()) {
if (!ignore_browser_checkpoint)
v8::MicrotasksScope::PerformCheckpoint(isolate);
} else {
v8_microtasks_scope_.emplace(isolate, microtask_queue, scope_type);
}
}
MicrotasksScope::~MicrotasksScope() = default;
} // namespace gin_helper