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

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: Fixed win compile error. 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 DCHECK_EQ(new_deadline, idle_period_deadline_); 355 DCHECK_EQ(new_deadline, idle_period_deadline_);
356 return; 356 return;
357 } 357 }
358 358
359 bool is_tracing; 359 bool is_tracing;
360 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing); 360 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing);
361 if (is_tracing) { 361 if (is_tracing) {
362 base::TimeTicks now(optional_now.is_null() 362 base::TimeTicks now(optional_now.is_null()
363 ? helper_->tick_clock()->NowTicks() 363 ? helper_->tick_clock()->NowTicks()
364 : optional_now); 364 : optional_now);
365 base::TraceTicks trace_now = base::TraceTicks::Now();
366 idle_period_deadline_for_tracing_ = trace_now + (new_deadline - now);
367 TraceEventIdlePeriodStateChange( 365 TraceEventIdlePeriodStateChange(
368 new_state, running_idle_task_for_tracing_, 366 new_state, running_idle_task_for_tracing_, idle_period_deadline_, now);
369 idle_period_deadline_for_tracing_, trace_now);
370 } 367 }
371 368
372 idle_period_state_ = new_state; 369 idle_period_state_ = new_state;
373 idle_period_deadline_ = new_deadline; 370 idle_period_deadline_ = new_deadline;
374 371
375 // Inform the delegate if we are starting or ending an idle period. 372 // Inform the delegate if we are starting or ending an idle period.
376 if (IsInIdlePeriod(new_state) && !IsInIdlePeriod(old_idle_period_state)) { 373 if (IsInIdlePeriod(new_state) && !IsInIdlePeriod(old_idle_period_state)) {
377 delegate_->OnIdlePeriodStarted(); 374 delegate_->OnIdlePeriodStarted();
378 } else if (!IsInIdlePeriod(new_state) && 375 } else if (!IsInIdlePeriod(new_state) &&
379 IsInIdlePeriod(old_idle_period_state)) { 376 IsInIdlePeriod(old_idle_period_state)) {
380 delegate_->OnIdlePeriodEnded(); 377 delegate_->OnIdlePeriodEnded();
381 } 378 }
382 } 379 }
383 380
384 void IdleHelper::State::TraceIdleIdleTaskStart() { 381 void IdleHelper::State::TraceIdleIdleTaskStart() {
385 helper_->CheckOnValidThread(); 382 helper_->CheckOnValidThread();
386 383
387 bool is_tracing; 384 bool is_tracing;
388 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing); 385 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing);
389 if (is_tracing) { 386 if (is_tracing) {
390 TraceEventIdlePeriodStateChange( 387 TraceEventIdlePeriodStateChange(
391 idle_period_state_, true, idle_period_deadline_for_tracing_, 388 idle_period_state_, true, idle_period_deadline_,
392 base::TraceTicks::Now()); 389 base::TimeTicks::Now());
393 } 390 }
394 } 391 }
395 392
396 void IdleHelper::State::TraceIdleIdleTaskEnd() { 393 void IdleHelper::State::TraceIdleIdleTaskEnd() {
397 helper_->CheckOnValidThread(); 394 helper_->CheckOnValidThread();
398 395
399 bool is_tracing; 396 bool is_tracing;
400 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing); 397 TRACE_EVENT_CATEGORY_GROUP_ENABLED(tracing_category_, &is_tracing);
401 if (is_tracing) { 398 if (is_tracing) {
402 TraceEventIdlePeriodStateChange( 399 TraceEventIdlePeriodStateChange(
403 idle_period_state_, false, idle_period_deadline_for_tracing_, 400 idle_period_state_, false, idle_period_deadline_,
404 base::TraceTicks::Now()); 401 base::TimeTicks::Now());
405 } 402 }
406 } 403 }
407 404
408 void IdleHelper::State::TraceEventIdlePeriodStateChange( 405 void IdleHelper::State::TraceEventIdlePeriodStateChange(
409 IdlePeriodState new_state, 406 IdlePeriodState new_state,
410 bool new_running_idle_task, 407 bool new_running_idle_task,
411 base::TraceTicks new_deadline, 408 base::TimeTicks new_deadline,
412 base::TraceTicks now) { 409 base::TimeTicks now) {
413 TRACE_EVENT2(disabled_by_default_tracing_category_, "SetIdlePeriodState", 410 TRACE_EVENT2(disabled_by_default_tracing_category_, "SetIdlePeriodState",
414 "old_state", 411 "old_state",
415 IdleHelper::IdlePeriodStateToString(idle_period_state_), 412 IdleHelper::IdlePeriodStateToString(idle_period_state_),
416 "new_state", IdleHelper::IdlePeriodStateToString(new_state)); 413 "new_state", IdleHelper::IdlePeriodStateToString(new_state));
417 414
418 if (idle_period_trace_event_started_ && running_idle_task_for_tracing_ && 415 if (idle_period_trace_event_started_ && running_idle_task_for_tracing_ &&
419 !new_running_idle_task) { 416 !new_running_idle_task) {
420 running_idle_task_for_tracing_ = false; 417 running_idle_task_for_tracing_ = false;
421 if (!idle_period_deadline_for_tracing_.is_null() && 418 if (!idle_period_deadline_.is_null() && now > idle_period_deadline_) {
422 now > idle_period_deadline_for_tracing_) {
423 TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0( 419 TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0(
424 tracing_category_, idle_period_tracing_name_, this, 420 tracing_category_, idle_period_tracing_name_, this,
425 "DeadlineOverrun", 421 "DeadlineOverrun",
426 std::max(idle_period_deadline_for_tracing_, 422 std::max(idle_period_deadline_,
427 last_idle_task_trace_time_).ToInternalValue()); 423 last_idle_task_trace_time_).ToInternalValue());
428 } 424 }
429 } 425 }
430 426
431 if (IsInIdlePeriod(new_state)) { 427 if (IsInIdlePeriod(new_state)) {
432 if (!idle_period_trace_event_started_) { 428 if (!idle_period_trace_event_started_) {
433 idle_period_trace_event_started_ = true; 429 idle_period_trace_event_started_ = true;
434 TRACE_EVENT_ASYNC_BEGIN1( 430 TRACE_EVENT_ASYNC_BEGIN1(
435 tracing_category_, idle_period_tracing_name_, this, 431 tracing_category_, idle_period_tracing_name_, this,
436 "idle_period_length_ms", (new_deadline - now).ToInternalValue()); 432 "idle_period_length_ms", (new_deadline - now).ToInternalValue());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 return "in_long_idle_period_with_max_deadline"; 472 return "in_long_idle_period_with_max_deadline";
477 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED: 473 case IdlePeriodState::IN_LONG_IDLE_PERIOD_PAUSED:
478 return "in_long_idle_period_paused"; 474 return "in_long_idle_period_paused";
479 default: 475 default:
480 NOTREACHED(); 476 NOTREACHED();
481 return nullptr; 477 return nullptr;
482 } 478 }
483 } 479 }
484 480
485 } // namespace scheduler 481 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/child/idle_helper.h ('k') | components/startup_metric_utils/browser/startup_metric_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698