web_worker_observer.h 949 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright (c) 2017 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_RENDERER_WEB_WORKER_OBSERVER_H_
  5. #define ATOM_RENDERER_WEB_WORKER_OBSERVER_H_
  6. #include <memory>
  7. #include "base/macros.h"
  8. #include "v8/include/v8.h"
  9. namespace atom {
  10. class AtomBindings;
  11. class NodeBindings;
  12. // Watches for WebWorker and insert node integration to it.
  13. class WebWorkerObserver {
  14. public:
  15. // Returns the WebWorkerObserver for current worker thread.
  16. static WebWorkerObserver* GetCurrent();
  17. void ContextCreated(v8::Local<v8::Context> context);
  18. void ContextWillDestroy(v8::Local<v8::Context> context);
  19. private:
  20. WebWorkerObserver();
  21. ~WebWorkerObserver();
  22. std::unique_ptr<NodeBindings> node_bindings_;
  23. std::unique_ptr<AtomBindings> atom_bindings_;
  24. DISALLOW_COPY_AND_ASSIGN(WebWorkerObserver);
  25. };
  26. } // namespace atom
  27. #endif // ATOM_RENDERER_WEB_WORKER_OBSERVER_H_