2017-03-07 03:35:03 -07: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 00:34:31 -07:00
|
|
|
#ifndef ELECTRON_SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|
|
|
|
#define ELECTRON_SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|
2017-03-07 03:35:03 -07:00
|
|
|
|
2018-09-12 18:25:56 -06:00
|
|
|
#include <memory>
|
2023-08-23 07:56:16 -06:00
|
|
|
#include <set>
|
2018-09-12 18:25:56 -06:00
|
|
|
|
2017-03-07 03:35:03 -07:00
|
|
|
#include "v8/include/v8.h"
|
|
|
|
|
2023-08-23 07:56:16 -06:00
|
|
|
namespace node {
|
|
|
|
|
|
|
|
class Environment;
|
|
|
|
|
|
|
|
} // namespace node
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
namespace electron {
|
2017-03-07 03:35:03 -07:00
|
|
|
|
2019-03-18 13:37:06 -06:00
|
|
|
class ElectronBindings;
|
2017-03-07 03:35:03 -07:00
|
|
|
class NodeBindings;
|
|
|
|
|
|
|
|
// Watches for WebWorker and insert node integration to it.
|
|
|
|
class WebWorkerObserver {
|
|
|
|
public:
|
2023-01-31 04:29:29 -07:00
|
|
|
WebWorkerObserver();
|
|
|
|
~WebWorkerObserver();
|
|
|
|
|
2017-03-07 03:35:03 -07:00
|
|
|
// Returns the WebWorkerObserver for current worker thread.
|
|
|
|
static WebWorkerObserver* GetCurrent();
|
2023-01-31 04:29:29 -07:00
|
|
|
// Creates a new WebWorkerObserver for a given context.
|
|
|
|
static WebWorkerObserver* Create();
|
2017-03-07 03:35:03 -07:00
|
|
|
|
2021-11-03 05:41:45 -06:00
|
|
|
// disable copy
|
|
|
|
WebWorkerObserver(const WebWorkerObserver&) = delete;
|
|
|
|
WebWorkerObserver& operator=(const WebWorkerObserver&) = delete;
|
|
|
|
|
2020-07-27 19:48:37 -06:00
|
|
|
void WorkerScriptReadyForEvaluation(v8::Local<v8::Context> context);
|
2017-03-07 03:35:03 -07:00
|
|
|
void ContextWillDestroy(v8::Local<v8::Context> context);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<NodeBindings> node_bindings_;
|
2019-03-18 13:37:06 -06:00
|
|
|
std::unique_ptr<ElectronBindings> electron_bindings_;
|
2023-08-23 07:56:16 -06:00
|
|
|
std::set<std::shared_ptr<node::Environment>> environments_;
|
2017-03-07 03:35:03 -07:00
|
|
|
};
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
} // namespace electron
|
2017-03-07 03:35:03 -07:00
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#endif // ELECTRON_SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|