| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 int64 new_delay_ms = idle_notification_delay_in_ms_ + | 619 int64 new_delay_ms = idle_notification_delay_in_ms_ + |
| 620 1000000 / (idle_notification_delay_in_ms_ + 2000); | 620 1000000 / (idle_notification_delay_in_ms_ + 2000); |
| 621 if (new_delay_ms >= kLongIdleHandlerDelayMs) | 621 if (new_delay_ms >= kLongIdleHandlerDelayMs) |
| 622 new_delay_ms = kShortIdleHandlerDelayMs; | 622 new_delay_ms = kShortIdleHandlerDelayMs; |
| 623 | 623 |
| 624 if (idle_notifications_to_skip_ > 0) { | 624 if (idle_notifications_to_skip_ > 0) { |
| 625 idle_notifications_to_skip_--; | 625 idle_notifications_to_skip_--; |
| 626 } else { | 626 } else { |
| 627 int cpu_usage = 0; | 627 int cpu_usage = 0; |
| 628 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage)); | 628 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage)); |
| 629 // Idle notification hint roughly specifies the expected duration of the |
| 630 // idle pause. We set it proportional to the idle timer delay. |
| 631 int idle_hint = static_cast<int>(new_delay_ms / 10); |
| 629 if (cpu_usage < kIdleCPUUsageThresholdInPercents && | 632 if (cpu_usage < kIdleCPUUsageThresholdInPercents && |
| 630 v8::V8::IdleNotification()) { | 633 v8::V8::IdleNotification(idle_hint)) { |
| 631 // V8 finished collecting garbage. | 634 // V8 finished collecting garbage. |
| 632 new_delay_ms = kLongIdleHandlerDelayMs; | 635 new_delay_ms = kLongIdleHandlerDelayMs; |
| 633 } | 636 } |
| 634 } | 637 } |
| 635 ScheduleIdleHandler(new_delay_ms); | 638 ScheduleIdleHandler(new_delay_ms); |
| 636 } | 639 } |
| 637 | 640 |
| 638 int64 RenderThreadImpl::GetIdleNotificationDelayInMs() const { | 641 int64 RenderThreadImpl::GetIdleNotificationDelayInMs() const { |
| 639 return idle_notification_delay_in_ms_; | 642 return idle_notification_delay_in_ms_; |
| 640 } | 643 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 | 849 |
| 847 scoped_refptr<base::MessageLoopProxy> | 850 scoped_refptr<base::MessageLoopProxy> |
| 848 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 851 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
| 849 DCHECK(message_loop() == MessageLoop::current()); | 852 DCHECK(message_loop() == MessageLoop::current()); |
| 850 if (!file_thread_.get()) { | 853 if (!file_thread_.get()) { |
| 851 file_thread_.reset(new base::Thread("Renderer::FILE")); | 854 file_thread_.reset(new base::Thread("Renderer::FILE")); |
| 852 file_thread_->Start(); | 855 file_thread_->Start(); |
| 853 } | 856 } |
| 854 return file_thread_->message_loop_proxy(); | 857 return file_thread_->message_loop_proxy(); |
| 855 } | 858 } |
| OLD | NEW |