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

Side by Side Diff: components/scheduler/child/idle_helper.cc

Issue 1424703003: Kills TraceTicks, which was functionally the same as TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 "components/scheduler/child/idle_helper.h" 5 #include "components/scheduler/child/idle_helper.h"
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "base/trace_event/trace_event_argument.h" 9 #include "base/trace_event/trace_event_argument.h"
10 #include "components/scheduler/base/task_queue.h" 10 #include "components/scheduler/base/task_queue.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 helper_->CheckOnValidThread(); 352 helper_->CheckOnValidThread();
353 if (new_state == idle_period_state_) { 353 if (new_state == idle_period_state_) {
354 DCHECK_EQ(new_deadline, idle_period_deadline_); 354 DCHECK_EQ(new_deadline, idle_period_deadline_);
355 return; 355 return;
356 } 356 }
357 357
358 bool is_tracing; 358 bool is_tracing;
359 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing); 359 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing);
360 if (is_tracing) { 360 if (is_tracing) {
361 base::TimeTicks now(optional_now.is_null() ? helper_->Now() : optional_now); 361 base::TimeTicks now(optional_now.is_null() ? helper_->Now() : optional_now);
362 base::TraceTicks trace_now = base::TraceTicks::Now();
363 idle_period_deadline_for_tracing_ = trace_now + (new_deadline - now);
364 TraceEventIdlePeriodStateChange( 362 TraceEventIdlePeriodStateChange(
365 new_state, running_idle_task_for_tracing_, 363 new_state, running_idle_task_for_tracing_, idle_period_deadline_, now);
366 idle_period_deadline_for_tracing_, trace_now);
367 } 364 }
368 365
369 idle_period_state_ = new_state; 366 idle_period_state_ = new_state;
370 idle_period_deadline_ = new_deadline; 367 idle_period_deadline_ = new_deadline;
371 368
372 // Inform the delegate if we are starting or ending an idle period. 369 // Inform the delegate if we are starting or ending an idle period.
373 if (IsInIdlePeriod(new_state) && !IsInIdlePeriod(old_idle_period_state)) { 370 if (IsInIdlePeriod(new_state) && !IsInIdlePeriod(old_idle_period_state)) {
374 delegate_->OnIdlePeriodStarted(); 371 delegate_->OnIdlePeriodStarted();
375 } else if (!IsInIdlePeriod(new_state) && 372 } else if (!IsInIdlePeriod(new_state) &&
376 IsInIdlePeriod(old_idle_period_state)) { 373 IsInIdlePeriod(old_idle_period_state)) {
377 delegate_->OnIdlePeriodEnded(); 374 delegate_->OnIdlePeriodEnded();
378 } 375 }
379 } 376 }
380 377
381 void IdleHelper::State::TraceIdleIdleTaskStart() { 378 void IdleHelper::State::TraceIdleIdleTaskStart() {
382 helper_->CheckOnValidThread(); 379 helper_->CheckOnValidThread();
383 380
384 bool is_tracing; 381 bool is_tracing;
385 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing); 382 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing);
386 if (is_tracing) { 383 if (is_tracing) {
387 TraceEventIdlePeriodStateChange( 384 TraceEventIdlePeriodStateChange(
388 idle_period_state_, true, idle_period_deadline_for_tracing_, 385 idle_period_state_, true, idle_period_deadline_,
389 base::TraceTicks::Now()); 386 base::TimeTicks::Now());
390 } 387 }
391 } 388 }
392 389
393 void IdleHelper::State::TraceIdleIdleTaskEnd() { 390 void IdleHelper::State::TraceIdleIdleTaskEnd() {
394 helper_->CheckOnValidThread(); 391 helper_->CheckOnValidThread();
395 392
396 bool is_tracing; 393 bool is_tracing;
397 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing); 394 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing);
398 if (is_tracing) { 395 if (is_tracing) {
399 TraceEventIdlePeriodStateChange( 396 TraceEventIdlePeriodStateChange(
400 idle_period_state_, false, idle_period_deadline_for_tracing_, 397 idle_period_state_, false, idle_period_deadline_,
401 base::TraceTicks::Now()); 398 base::TimeTicks::Now());
402 } 399 }
403 } 400 }
404 401
405 void IdleHelper::State::TraceEventIdlePeriodStateChange( 402 void IdleHelper::State::TraceEventIdlePeriodStateChange(
406 IdlePeriodState new_state, 403 IdlePeriodState new_state,
407 bool new_running_idle_task, 404 bool new_running_idle_task,
408 base::TraceTicks new_deadline, 405 base::TimeTicks new_deadline,
409 base::TraceTicks now) { 406 base::TimeTicks now) {
410 TRACE_EVENT2(disabled_by_default_tracing_category_, "SetIdlePeriodState", 407 TRACE_EVENT2(disabled_by_default_tracing_category_, "SetIdlePeriodState",
411 "old_state", 408 "old_state",
412 IdleHelper::IdlePeriodStateToString(idle_period_state_), 409 IdleHelper::IdlePeriodStateToString(idle_period_state_),
413 "new_state", IdleHelper::IdlePeriodStateToString(new_state)); 410 "new_state", IdleHelper::IdlePeriodStateToString(new_state));
414 411
415 if (idle_period_trace_event_started_ && running_idle_task_for_tracing_ && 412 if (idle_period_trace_event_started_ && running_idle_task_for_tracing_ &&
416 !new_running_idle_task) { 413 !new_running_idle_task) {
417 running_idle_task_for_tracing_ = false; 414 running_idle_task_for_tracing_ = false;
418 if (!idle_period_deadline_for_tracing_.is_null() && 415 if (!idle_period_deadline_.is_null() && now > idle_period_deadline_) {
419 now > idle_period_deadline_for_tracing_) {
420 TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0( 416 TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0(
421 tracing_category_, idle_period_tracing_name_, this, 417 tracing_category_, idle_period_tracing_name_, this,
422 "DeadlineOverrun", 418 "DeadlineOverrun",
423 std::max(idle_period_deadline_for_tracing_, 419 std::max(idle_period_deadline_,
424 last_idle_task_trace_time_).ToInternalValue()); 420 last_idle_task_time_).ToInternalValue());
425 } 421 }
426 } 422 }
427 423
428 if (IsInIdlePeriod(new_state)) { 424 if (IsInIdlePeriod(new_state)) {
429 if (!idle_period_trace_event_started_) { 425 if (!idle_period_trace_event_started_) {
430 idle_period_trace_event_started_ = true; 426 idle_period_trace_event_started_ = true;
431 TRACE_EVENT_ASYNC_BEGIN1( 427 TRACE_EVENT_ASYNC_BEGIN1(
432 tracing_category_, idle_period_tracing_name_, this, 428 tracing_category_, idle_period_tracing_name_, this,
433 "idle_period_length_ms", (new_deadline - now).ToInternalValue()); 429 "idle_period_length_ms", (new_deadline - now).ToInternalValue());
434 } 430 }
435 431
436 if (new_running_idle_task) { 432 if (new_running_idle_task) {
437 last_idle_task_trace_time_ = now; 433 last_idle_task_time_ = now;
438 running_idle_task_for_tracing_ = true; 434 running_idle_task_for_tracing_ = true;
439 TRACE_EVENT_ASYNC_STEP_INTO0( 435 TRACE_EVENT_ASYNC_STEP_INTO0(
440 tracing_category_, idle_period_tracing_name_, this, 436 tracing_category_, idle_period_tracing_name_, this,
441 "RunningIdleTask"); 437 "RunningIdleTask");
442 } else if (new_state == IdlePeriodState::IN_SHORT_IDLE_PERIOD) { 438 } else if (new_state == IdlePeriodState::IN_SHORT_IDLE_PERIOD) {
443 TRACE_EVENT_ASYNC_STEP_INTO0( 439 TRACE_EVENT_ASYNC_STEP_INTO0(
444 tracing_category_, idle_period_tracing_name_, this, 440 tracing_category_, idle_period_tracing_name_, this,
445 "ShortIdlePeriod"); 441 "ShortIdlePeriod");
446 } else if (IsInLongIdlePeriod(new_state) && 442 } else if (IsInLongIdlePeriod(new_state) &&
447 new_state != IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED) { 443 new_state != IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED) {
(...skipping 25 matching lines...) Expand all
473 return "in_long_idle_period_with_max_deadline"; 469 return "in_long_idle_period_with_max_deadline";
474 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED: 470 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED:
475 return "in_long_idle_period_paused"; 471 return "in_long_idle_period_paused";
476 default: 472 default:
477 NOTREACHED(); 473 NOTREACHED();
478 return nullptr; 474 return nullptr;
479 } 475 }
480 } 476 }
481 477
482 } // namespace scheduler 478 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698