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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 10239012: Route calls to tcmalloc MallocExtension through allocator agnostic interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: separate allocator_extension into own static library, add comments to allocator_extension.h Created 8 years, 7 months 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 | Annotate | Revision Log
OLDNEW
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>
11 11
12 #include "base/allocator/allocator_extension.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/debug/trace_event.h" 14 #include "base/debug/trace_event.h"
14 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/metrics/field_trial.h" 17 #include "base/metrics/field_trial.h"
17 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
18 #include "base/metrics/stats_table.h" 19 #include "base/metrics/stats_table.h"
19 #include "base/path_service.h" 20 #include "base/path_service.h"
20 #include "base/shared_memory.h" 21 #include "base/shared_memory.h"
21 #include "base/string_number_conversions.h" // Temporary 22 #include "base/string_number_conversions.h" // Temporary
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "content/renderer/render_process_impl.h" 57 #include "content/renderer/render_process_impl.h"
57 #include "content/renderer/render_view_impl.h" 58 #include "content/renderer/render_view_impl.h"
58 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 59 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
59 #include "content/renderer/renderer_webstoragearea_impl.h" 60 #include "content/renderer/renderer_webstoragearea_impl.h"
60 #include "grit/content_resources.h" 61 #include "grit/content_resources.h"
61 #include "ipc/ipc_channel_handle.h" 62 #include "ipc/ipc_channel_handle.h"
62 #include "ipc/ipc_platform_file.h" 63 #include "ipc/ipc_platform_file.h"
63 #include "media/base/media.h" 64 #include "media/base/media.h"
64 #include "net/base/net_errors.h" 65 #include "net/base/net_errors.h"
65 #include "net/base/net_util.h" 66 #include "net/base/net_util.h"
66 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
67 #include "third_party/WebKit/Source/WebKit/chromium/public/WebColorName.h" 67 #include "third_party/WebKit/Source/WebKit/chromium/public/WebColorName.h"
68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h"
69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h"
70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h"
74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h " 76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h "
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 630 }
631 631
632 void RenderThreadImpl::IdleHandler() { 632 void RenderThreadImpl::IdleHandler() {
633 bool run_in_foreground_tab = (widget_count_ > hidden_widget_count_) && 633 bool run_in_foreground_tab = (widget_count_ > hidden_widget_count_) &&
634 content::GetContentClient()->renderer()-> 634 content::GetContentClient()->renderer()->
635 RunIdleHandlerWhenWidgetsHidden(); 635 RunIdleHandlerWhenWidgetsHidden();
636 if (run_in_foreground_tab) { 636 if (run_in_foreground_tab) {
637 IdleHandlerInForegroundTab(); 637 IdleHandlerInForegroundTab();
638 return; 638 return;
639 } 639 }
640 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 640
641 MallocExtension::instance()->ReleaseFreeMemory(); 641 base::allocator::ReleaseFreeMemory();
642 #endif
643 642
644 v8::V8::IdleNotification(); 643 v8::V8::IdleNotification();
645 644
646 // Schedule next invocation. 645 // Schedule next invocation.
647 // Dampen the delay using the algorithm (if delay is in seconds): 646 // Dampen the delay using the algorithm (if delay is in seconds):
648 // delay = delay + 1 / (delay + 2) 647 // delay = delay + 1 / (delay + 2)
649 // Using floor(delay) has a dampening effect such as: 648 // Using floor(delay) has a dampening effect such as:
650 // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ... 649 // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
651 // If the delay is in milliseconds, the above formula is equivalent to: 650 // If the delay is in milliseconds, the above formula is equivalent to:
652 // delay_ms / 1000 = delay_ms / 1000 + 1 / (delay_ms / 1000 + 2) 651 // delay_ms / 1000 = delay_ms / 1000 + 1 / (delay_ms / 1000 + 2)
(...skipping 17 matching lines...) Expand all
670 669
671 if (idle_notifications_to_skip_ > 0) { 670 if (idle_notifications_to_skip_ > 0) {
672 idle_notifications_to_skip_--; 671 idle_notifications_to_skip_--;
673 } else { 672 } else {
674 int cpu_usage = 0; 673 int cpu_usage = 0;
675 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage)); 674 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage));
676 // Idle notification hint roughly specifies the expected duration of the 675 // Idle notification hint roughly specifies the expected duration of the
677 // idle pause. We set it proportional to the idle timer delay. 676 // idle pause. We set it proportional to the idle timer delay.
678 int idle_hint = static_cast<int>(new_delay_ms / 10); 677 int idle_hint = static_cast<int>(new_delay_ms / 10);
679 if (cpu_usage < kIdleCPUUsageThresholdInPercents) { 678 if (cpu_usage < kIdleCPUUsageThresholdInPercents) {
680 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 679 base::allocator::ReleaseFreeMemory();
681 MallocExtension::instance()->ReleaseFreeMemory();
682 #endif
683 if (v8::V8::IdleNotification(idle_hint)) { 680 if (v8::V8::IdleNotification(idle_hint)) {
684 // V8 finished collecting garbage. 681 // V8 finished collecting garbage.
685 new_delay_ms = kLongIdleHandlerDelayMs; 682 new_delay_ms = kLongIdleHandlerDelayMs;
686 } 683 }
687 } 684 }
688 } 685 }
689 ScheduleIdleHandler(new_delay_ms); 686 ScheduleIdleHandler(new_delay_ms);
690 } 687 }
691 688
692 int64 RenderThreadImpl::GetIdleNotificationDelayInMs() const { 689 int64 RenderThreadImpl::GetIdleNotificationDelayInMs() const {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 995
999 scoped_refptr<base::MessageLoopProxy> 996 scoped_refptr<base::MessageLoopProxy>
1000 RenderThreadImpl::GetFileThreadMessageLoopProxy() { 997 RenderThreadImpl::GetFileThreadMessageLoopProxy() {
1001 DCHECK(message_loop() == MessageLoop::current()); 998 DCHECK(message_loop() == MessageLoop::current());
1002 if (!file_thread_.get()) { 999 if (!file_thread_.get()) {
1003 file_thread_.reset(new base::Thread("Renderer::FILE")); 1000 file_thread_.reset(new base::Thread("Renderer::FILE"));
1004 file_thread_->Start(); 1001 file_thread_->Start();
1005 } 1002 }
1006 return file_thread_->message_loop_proxy(); 1003 return file_thread_->message_loop_proxy();
1007 } 1004 }
OLDNEW
« content/app/content_main_runner.cc ('K') | « content/common/child_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698