web_worker_observer.h 930 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 "base/macros.h"
  7. #include "v8/include/v8.h"
  8. namespace atom {
  9. class AtomBindings;
  10. class NodeBindings;
  11. // Watches for WebWorker and insert node integration to it.
  12. class WebWorkerObserver {
  13. public:
  14. // Returns the WebWorkerObserver for current worker thread.
  15. static WebWorkerObserver* GetCurrent();
  16. void ContextCreated(v8::Local<v8::Context> context);
  17. void ContextWillDestroy(v8::Local<v8::Context> context);
  18. private:
  19. WebWorkerObserver();
  20. ~WebWorkerObserver();
  21. std::unique_ptr<NodeBindings> node_bindings_;
  22. std::unique_ptr<AtomBindings> atom_bindings_;
  23. DISALLOW_COPY_AND_ASSIGN(WebWorkerObserver);
  24. };
  25. } // namespace atom
  26. #endif // ATOM_RENDERER_WEB_WORKER_OBSERVER_H_