2017-03-07 19:35:03 +09:00
|
|
|
// Copyright (c) 2017 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 08:34:31 +01:00
|
|
|
#ifndef ELECTRON_SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|
|
|
|
#define ELECTRON_SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|
2017-03-07 19:35:03 +09:00
|
|
|
|
2018-09-12 19:25:56 -05:00
|
|
|
#include <memory>
|
|
|
|
|
2024-01-05 05:18:31 -06:00
|
|
|
#include "base/containers/flat_set.h"
|
2017-03-07 19:35:03 +09:00
|
|
|
#include "v8/include/v8.h"
|
|
|
|
|
2023-08-23 08:56:16 -05:00
|
|
|
namespace node {
|
|
|
|
|
|
|
|
class Environment;
|
|
|
|
|
|
|
|
} // namespace node
|
|
|
|
|
2019-06-19 14:23:04 -07:00
|
|
|
namespace electron {
|
2017-03-07 19:35:03 +09:00
|
|
|
|
2019-03-18 12:37:06 -07:00
|
|
|
class ElectronBindings;
|
2017-03-07 19:35:03 +09:00
|
|
|
class NodeBindings;
|
|
|
|
|
|
|
|
// Watches for WebWorker and insert node integration to it.
|
|
|
|
class WebWorkerObserver {
|
|
|
|
public:
|
2023-01-31 12:29:29 +01:00
|
|
|
WebWorkerObserver();
|
|
|
|
~WebWorkerObserver();
|
|
|
|
|
2017-03-07 19:35:03 +09:00
|
|
|
// Returns the WebWorkerObserver for current worker thread.
|
|
|
|
static WebWorkerObserver* GetCurrent();
|
2023-01-31 12:29:29 +01:00
|
|
|
// Creates a new WebWorkerObserver for a given context.
|
|
|
|
static WebWorkerObserver* Create();
|
2017-03-07 19:35:03 +09:00
|
|
|
|
2021-11-03 12:41:45 +01:00
|
|
|
// disable copy
|
|
|
|
WebWorkerObserver(const WebWorkerObserver&) = delete;
|
|
|
|
WebWorkerObserver& operator=(const WebWorkerObserver&) = delete;
|
|
|
|
|
2020-07-27 18:48:37 -07:00
|
|
|
void WorkerScriptReadyForEvaluation(v8::Local<v8::Context> context);
|
2017-03-07 19:35:03 +09:00
|
|
|
void ContextWillDestroy(v8::Local<v8::Context> context);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<NodeBindings> node_bindings_;
|
2019-03-18 12:37:06 -07:00
|
|
|
std::unique_ptr<ElectronBindings> electron_bindings_;
|
2024-01-05 05:18:31 -06:00
|
|
|
base::flat_set<std::shared_ptr<node::Environment>> environments_;
|
2017-03-07 19:35:03 +09:00
|
|
|
};
|
|
|
|
|
2019-06-19 14:23:04 -07:00
|
|
|
} // namespace electron
|
2017-03-07 19:35:03 +09:00
|
|
|
|
2021-11-22 08:34:31 +01:00
|
|
|
#endif // ELECTRON_SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|