2017-03-07 10:35:03 +00: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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|
|
|
|
#define SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|
2017-03-07 10:35:03 +00:00
|
|
|
|
2018-09-13 00:25:56 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-03-07 10:35:03 +00:00
|
|
|
#include "v8/include/v8.h"
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2017-03-07 10:35:03 +00:00
|
|
|
|
2019-03-18 19:37:06 +00:00
|
|
|
class ElectronBindings;
|
2017-03-07 10:35:03 +00:00
|
|
|
class NodeBindings;
|
|
|
|
|
|
|
|
// Watches for WebWorker and insert node integration to it.
|
|
|
|
class WebWorkerObserver {
|
|
|
|
public:
|
|
|
|
// Returns the WebWorkerObserver for current worker thread.
|
|
|
|
static WebWorkerObserver* GetCurrent();
|
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
WebWorkerObserver(const WebWorkerObserver&) = delete;
|
|
|
|
WebWorkerObserver& operator=(const WebWorkerObserver&) = delete;
|
|
|
|
|
2020-07-28 01:48:37 +00:00
|
|
|
void WorkerScriptReadyForEvaluation(v8::Local<v8::Context> context);
|
2017-03-07 10:35:03 +00:00
|
|
|
void ContextWillDestroy(v8::Local<v8::Context> context);
|
|
|
|
|
|
|
|
private:
|
|
|
|
WebWorkerObserver();
|
|
|
|
~WebWorkerObserver();
|
|
|
|
|
|
|
|
std::unique_ptr<NodeBindings> node_bindings_;
|
2019-03-18 19:37:06 +00:00
|
|
|
std::unique_ptr<ElectronBindings> electron_bindings_;
|
2017-03-07 10:35:03 +00:00
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2017-03-07 10:35:03 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_RENDERER_WEB_WORKER_OBSERVER_H_
|