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

Unified Diff: src/libplatform/default-platform.cc

Issue 2737743002: Make idle tasks optional in the default platform. (Closed)
Patch Set: another fix Created 3 years, 9 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 | « src/libplatform/default-platform.h ('k') | test/unittests/libplatform/default-platform-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/libplatform/default-platform.cc
diff --git a/src/libplatform/default-platform.cc b/src/libplatform/default-platform.cc
index 0e2144b64844d9f8389d4b63930019e8536ed25d..eab609b531fda81b7ac81080f62f70f27d0fe221 100644
--- a/src/libplatform/default-platform.cc
+++ b/src/libplatform/default-platform.cc
@@ -17,9 +17,9 @@
namespace v8 {
namespace platform {
-
-v8::Platform* CreateDefaultPlatform(int thread_pool_size) {
- DefaultPlatform* platform = new DefaultPlatform();
+v8::Platform* CreateDefaultPlatform(int thread_pool_size,
+ IdleTaskSupport idle_task_support) {
+ DefaultPlatform* platform = new DefaultPlatform(idle_task_support);
platform->SetThreadPoolSize(thread_pool_size);
platform->EnsureInitialized();
return platform;
@@ -45,8 +45,10 @@ void SetTracingController(
const int DefaultPlatform::kMaxThreadPoolSize = 8;
-DefaultPlatform::DefaultPlatform()
- : initialized_(false), thread_pool_size_(0) {}
+DefaultPlatform::DefaultPlatform(IdleTaskSupport idle_task_support)
+ : initialized_(false),
+ thread_pool_size_(0),
+ idle_task_support_(idle_task_support) {}
DefaultPlatform::~DefaultPlatform() {
if (tracing_controller_) {
@@ -165,6 +167,7 @@ bool DefaultPlatform::PumpMessageLoop(v8::Isolate* isolate) {
void DefaultPlatform::RunIdleTasks(v8::Isolate* isolate,
double idle_time_in_seconds) {
+ DCHECK(IdleTaskSupport::kEnabled == idle_task_support_);
double deadline_in_seconds =
MonotonicallyIncreasingTime() + idle_time_in_seconds;
while (deadline_in_seconds > MonotonicallyIncreasingTime()) {
@@ -208,7 +211,9 @@ void DefaultPlatform::CallIdleOnForegroundThread(Isolate* isolate,
main_thread_idle_queue_[isolate].push(task);
}
-bool DefaultPlatform::IdleTasksEnabled(Isolate* isolate) { return true; }
+bool DefaultPlatform::IdleTasksEnabled(Isolate* isolate) {
+ return idle_task_support_ == IdleTaskSupport::kEnabled;
+}
double DefaultPlatform::MonotonicallyIncreasingTime() {
return base::TimeTicks::HighResolutionNow().ToInternalValue() /
« no previous file with comments | « src/libplatform/default-platform.h ('k') | test/unittests/libplatform/default-platform-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698