Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: gin/isolate_holder.cc

Issue 577733002: Mojo JS bindings: draining a DataPipe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More size_t Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/gin.gyp ('k') | gin/public/isolate_holder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/isolate_holder.cc
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index db4473ec0f9ee3d3976f8521523fd6a5459dbb18..00e9d845bd067327fbf90838b96ab08fccc9732f 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -8,6 +8,7 @@
#include <string.h>
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/sys_info.h"
#include "gin/array_buffer.h"
@@ -15,6 +16,7 @@
#include "gin/function_template.h"
#include "gin/per_isolate_data.h"
#include "gin/public/v8_platform.h"
+#include "gin/run_microtasks_observer.h"
namespace gin {
@@ -43,6 +45,8 @@ IsolateHolder::IsolateHolder() {
}
IsolateHolder::~IsolateHolder() {
+ if (task_observer_.get())
+ base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get());
isolate_data_.reset();
isolate_->Dispose();
}
@@ -66,4 +70,16 @@ void IsolateHolder::Initialize(ScriptMode mode,
v8_is_initialized = true;
}
+void IsolateHolder::AddRunMicrotasksObserver() {
+ DCHECK(!task_observer_.get());
+ task_observer_.reset(new RunMicrotasksObserver(isolate_));;
+ base::MessageLoop::current()->AddTaskObserver(task_observer_.get());
+}
+
+void IsolateHolder::RemoveRunMicrotasksObserver() {
+ DCHECK(task_observer_.get());
+ base::MessageLoop::current()->RemoveTaskObserver(task_observer_.get());
+ task_observer_.reset();
+}
+
} // namespace gin
« no previous file with comments | « gin/gin.gyp ('k') | gin/public/isolate_holder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698