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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc

Issue 2517383004: [scheduler] Bunch of improvements for blink scheduler tracing (Closed)
Patch Set: git cl try Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/scheduler/base/task_queue_impl.h" 5 #include "platform/scheduler/base/task_queue_impl.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/trace_event/blame_context.h" 9 #include "base/trace_event/blame_context.h"
10 #include "platform/scheduler/base/task_queue_manager.h" 10 #include "platform/scheduler/base/task_queue_manager.h"
(...skipping 30 matching lines...) Expand all
41 case TaskQueue::QueueType::TEST: 41 case TaskQueue::QueueType::TEST:
42 return "test_tq"; 42 return "test_tq";
43 case TaskQueue::QueueType::COUNT: 43 case TaskQueue::QueueType::COUNT:
44 DCHECK(false); 44 DCHECK(false);
45 return nullptr; 45 return nullptr;
46 } 46 }
47 DCHECK(false); 47 DCHECK(false);
48 return nullptr; 48 return nullptr;
49 } 49 }
50 50
51 // static
52 const char* TaskQueue::PriorityToString(QueuePriority priority) {
53 switch (priority) {
54 case CONTROL_PRIORITY:
55 return "control";
56 case HIGH_PRIORITY:
57 return "high";
58 case NORMAL_PRIORITY:
59 return "normal";
60 case BEST_EFFORT_PRIORITY:
61 return "best_effort";
62 default:
63 NOTREACHED();
64 return nullptr;
65 }
66 }
67
51 namespace internal { 68 namespace internal {
52 69
53 TaskQueueImpl::TaskQueueImpl( 70 TaskQueueImpl::TaskQueueImpl(
54 TaskQueueManager* task_queue_manager, 71 TaskQueueManager* task_queue_manager,
55 TimeDomain* time_domain, 72 TimeDomain* time_domain,
56 const Spec& spec, 73 const Spec& spec,
57 const char* disabled_by_default_tracing_category, 74 const char* disabled_by_default_tracing_category,
58 const char* disabled_by_default_verbose_tracing_category) 75 const char* disabled_by_default_verbose_tracing_category)
59 : thread_id_(base::PlatformThread::CurrentId()), 76 : thread_id_(base::PlatformThread::CurrentId()),
60 any_thread_(task_queue_manager, time_domain), 77 any_thread_(task_queue_manager, time_domain),
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 main_thread_only().task_queue_manager->selector_.SetQueuePriority(this, 491 main_thread_only().task_queue_manager->selector_.SetQueuePriority(this,
475 priority); 492 priority);
476 } 493 }
477 494
478 TaskQueueImpl::QueuePriority TaskQueueImpl::GetQueuePriority() const { 495 TaskQueueImpl::QueuePriority TaskQueueImpl::GetQueuePriority() const {
479 size_t set_index = immediate_work_queue()->work_queue_set_index(); 496 size_t set_index = immediate_work_queue()->work_queue_set_index();
480 DCHECK_EQ(set_index, delayed_work_queue()->work_queue_set_index()); 497 DCHECK_EQ(set_index, delayed_work_queue()->work_queue_set_index());
481 return static_cast<TaskQueue::QueuePriority>(set_index); 498 return static_cast<TaskQueue::QueuePriority>(set_index);
482 } 499 }
483 500
484 // static
485 const char* TaskQueueImpl::PriorityToString(QueuePriority priority) {
486 switch (priority) {
487 case CONTROL_PRIORITY:
488 return "control";
489 case HIGH_PRIORITY:
490 return "high";
491 case NORMAL_PRIORITY:
492 return "normal";
493 case BEST_EFFORT_PRIORITY:
494 return "best_effort";
495 default:
496 NOTREACHED();
497 return nullptr;
498 }
499 }
500
501 void TaskQueueImpl::AsValueInto(base::trace_event::TracedValue* state) const { 501 void TaskQueueImpl::AsValueInto(base::trace_event::TracedValue* state) const {
502 base::AutoLock lock(any_thread_lock_); 502 base::AutoLock lock(any_thread_lock_);
503 state->BeginDictionary(); 503 state->BeginDictionary();
504 state->SetString("name", GetName()); 504 state->SetString("name", GetName());
505 state->SetString( 505 state->SetString(
506 "id", base::StringPrintf( 506 "task_queue_id",
507 "%" PRIx64, 507 base::StringPrintf("%" PRIx64, static_cast<uint64_t>(
508 static_cast<uint64_t>(reinterpret_cast<uintptr_t>(this)))); 508 reinterpret_cast<uintptr_t>(this))));
509 state->SetBoolean("enabled", main_thread_only().is_enabled); 509 state->SetBoolean("enabled", main_thread_only().is_enabled);
510 state->SetString("time_domain_name", 510 state->SetString("time_domain_name",
511 main_thread_only().time_domain->GetName()); 511 main_thread_only().time_domain->GetName());
512 bool verbose_tracing_enabled = false; 512 bool verbose_tracing_enabled = false;
513 TRACE_EVENT_CATEGORY_GROUP_ENABLED( 513 TRACE_EVENT_CATEGORY_GROUP_ENABLED(
514 disabled_by_default_verbose_tracing_category_, &verbose_tracing_enabled); 514 disabled_by_default_verbose_tracing_category_, &verbose_tracing_enabled);
515 state->SetInteger("immediate_incoming_queue_size", 515 state->SetInteger("immediate_incoming_queue_size",
516 any_thread().immediate_incoming_queue.size()); 516 any_thread().immediate_incoming_queue.size());
517 state->SetInteger("delayed_incoming_queue_size", 517 state->SetInteger("delayed_incoming_queue_size",
518 main_thread_only().delayed_incoming_queue.size()); 518 main_thread_only().delayed_incoming_queue.size());
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 state->SetBoolean("is_cancelled", task.task.IsCancelled()); 749 state->SetBoolean("is_cancelled", task.task.IsCancelled());
750 state->SetDouble( 750 state->SetDouble(
751 "delayed_run_time", 751 "delayed_run_time",
752 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L); 752 (task.delayed_run_time - base::TimeTicks()).InMicroseconds() / 1000.0L);
753 state->EndDictionary(); 753 state->EndDictionary();
754 } 754 }
755 755
756 } // namespace internal 756 } // namespace internal
757 } // namespace scheduler 757 } // namespace scheduler
758 } // namespace blink 758 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698