atom_bindings.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2013 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_COMMON_API_ATOM_BINDINGS_H_
  5. #define ATOM_COMMON_API_ATOM_BINDINGS_H_
  6. #include <list>
  7. #include "base/macros.h"
  8. #include "base/strings/string16.h"
  9. #include "v8/include/v8.h"
  10. #include "vendor/node/deps/uv/include/uv.h"
  11. namespace node {
  12. class Environment;
  13. }
  14. namespace atom {
  15. class AtomBindings {
  16. public:
  17. AtomBindings();
  18. virtual ~AtomBindings();
  19. // Add process.atomBinding function, which behaves like process.binding but
  20. // load native code from Electron instead.
  21. void BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process);
  22. static void Log(const base::string16& message);
  23. static void Crash();
  24. private:
  25. void ActivateUVLoop(v8::Isolate* isolate);
  26. static void OnCallNextTick(uv_async_t* handle);
  27. uv_async_t call_next_tick_async_;
  28. std::list<node::Environment*> pending_next_ticks_;
  29. DISALLOW_COPY_AND_ASSIGN(AtomBindings);
  30. };
  31. } // namespace atom
  32. #endif // ATOM_COMMON_API_ATOM_BINDINGS_H_