OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 // Increase the delay in the same way as in IdleHandler, | 614 // Increase the delay in the same way as in IdleHandler, |
615 // but make it periodic by reseting it once it is too big. | 615 // but make it periodic by reseting it once it is too big. |
616 int64 new_delay_ms = idle_notification_delay_in_ms_ + | 616 int64 new_delay_ms = idle_notification_delay_in_ms_ + |
617 1000000 / (idle_notification_delay_in_ms_ + 2000); | 617 1000000 / (idle_notification_delay_in_ms_ + 2000); |
618 if (new_delay_ms >= kLongIdleHandlerDelayMs) | 618 if (new_delay_ms >= kLongIdleHandlerDelayMs) |
619 new_delay_ms = kShortIdleHandlerDelayMs; | 619 new_delay_ms = kShortIdleHandlerDelayMs; |
620 | 620 |
621 if (idle_notifications_to_skip_ > 0) { | 621 if (idle_notifications_to_skip_ > 0) { |
622 idle_notifications_to_skip_--; | 622 idle_notifications_to_skip_--; |
623 } else { | 623 } else { |
624 int cpu_usage; | 624 int cpu_usage = 0; |
625 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage)); | 625 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage)); |
626 if (cpu_usage < kIdleCPUUsageThresholdInPercents && | 626 if (cpu_usage < kIdleCPUUsageThresholdInPercents && |
627 v8::V8::IdleNotification()) { | 627 v8::V8::IdleNotification()) { |
628 // V8 finished collecting garbage. | 628 // V8 finished collecting garbage. |
629 new_delay_ms = kLongIdleHandlerDelayMs; | 629 new_delay_ms = kLongIdleHandlerDelayMs; |
630 } | 630 } |
631 } | 631 } |
632 ScheduleIdleHandler(new_delay_ms); | 632 ScheduleIdleHandler(new_delay_ms); |
633 } | 633 } |
634 | 634 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 | 845 |
846 scoped_refptr<base::MessageLoopProxy> | 846 scoped_refptr<base::MessageLoopProxy> |
847 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 847 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
848 DCHECK(message_loop() == MessageLoop::current()); | 848 DCHECK(message_loop() == MessageLoop::current()); |
849 if (!file_thread_.get()) { | 849 if (!file_thread_.get()) { |
850 file_thread_.reset(new base::Thread("Renderer::FILE")); | 850 file_thread_.reset(new base::Thread("Renderer::FILE")); |
851 file_thread_->Start(); | 851 file_thread_->Start(); |
852 } | 852 } |
853 return file_thread_->message_loop_proxy(); | 853 return file_thread_->message_loop_proxy(); |
854 } | 854 } |
OLD | NEW |