Add a new type of NodeBindings

This commit is contained in:
Cheng Zhao 2017-03-08 17:33:44 +09:00
parent aac934b34e
commit b467c3939e
11 changed files with 57 additions and 38 deletions

View file

@ -23,7 +23,13 @@ namespace atom {
class NodeBindings {
public:
static NodeBindings* Create(bool is_browser);
enum BrowserEnvironment {
BROWSER,
RENDERER,
WORKER,
};
static NodeBindings* Create(BrowserEnvironment browser_env);
virtual ~NodeBindings();
@ -47,7 +53,7 @@ class NodeBindings {
node::Environment* uv_env() const { return uv_env_; }
protected:
explicit NodeBindings(bool is_browser);
explicit NodeBindings(BrowserEnvironment browser_env);
// Called to poll events in new thread.
virtual void PollEvents() = 0;
@ -61,8 +67,8 @@ class NodeBindings {
// Interrupt the PollEvents.
void WakeupEmbedThread();
// Are we running in browser.
bool is_browser_;
// Which environment we are running.
BrowserEnvironment browser_env_;
// Main thread's MessageLoop.
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;