Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't specify v8::MicrotasksScope for explicit policy
- Loading branch information
1 parent
38669f8
commit 7d48eb0
Showing
12 changed files
with
88 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// 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/browser/electron_browser_main_parts.h" | ||
#include "shell/browser/javascript_environment.h" | ||
#include "shell/common/gin_helper/locker.h" | ||
#include "shell/common/node_includes.h" | ||
|
||
namespace gin_helper { | ||
|
||
MicrotasksScope::MicrotasksScope(v8::Isolate* isolate) { | ||
if (Locker::IsBrowserProcess()) { | ||
auto* node_env = electron::ElectronBrowserMainParts::Get()->node_env(); | ||
node_callback_scope_.reset(new node::InternalCallbackScope( | ||
node_env->env(), v8::Local<v8::Object>(), {0, 0}, | ||
node::InternalCallbackScope::kAllowEmptyResource)); | ||
} else { | ||
v8_microtasks_scope_ = std::make_unique<v8::MicrotasksScope>( | ||
isolate, v8::MicrotasksScope::kRunMicrotasks); | ||
} | ||
} | ||
|
||
MicrotasksScope::~MicrotasksScope() = default; | ||
|
||
} // namespace gin_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2020 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef SHELL_COMMON_GIN_HELPER_MICROTASKS_SCOPE_H_ | ||
#define SHELL_COMMON_GIN_HELPER_MICROTASKS_SCOPE_H_ | ||
|
||
#include <memory> | ||
|
||
#include "base/macros.h" | ||
#include "v8/include/v8.h" | ||
|
||
namespace node { | ||
class InternalCallbackScope; | ||
} | ||
|
||
namespace gin_helper { | ||
|
||
// In the browser process creates node::InternalCallbackScope | ||
// In the render process creates a v8::MicrotasksScope. | ||
class MicrotasksScope { | ||
public: | ||
explicit MicrotasksScope(v8::Isolate* isolate); | ||
~MicrotasksScope(); | ||
|
||
private: | ||
std::unique_ptr<v8::MicrotasksScope> v8_microtasks_scope_; | ||
std::unique_ptr<node::InternalCallbackScope> node_callback_scope_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(MicrotasksScope); | ||
}; | ||
|
||
} // namespace gin_helper | ||
|
||
#endif // SHELL_COMMON_GIN_HELPER_MICROTASKS_SCOPE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters