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

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: 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
« no previous file with comments | « content/common/child_thread.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 "content/renderer/renderer_webstoragenamespace_impl.h" 61 #include "content/renderer/renderer_webstoragenamespace_impl.h"
61 #include "grit/content_resources.h" 62 #include "grit/content_resources.h"
62 #include "ipc/ipc_channel_handle.h" 63 #include "ipc/ipc_channel_handle.h"
63 #include "ipc/ipc_platform_file.h" 64 #include "ipc/ipc_platform_file.h"
64 #include "media/base/media.h" 65 #include "media/base/media.h"
65 #include "net/base/net_errors.h" 66 #include "net/base/net_errors.h"
66 #include "net/base/net_util.h" 67 #include "net/base/net_util.h"
67 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebColorName.h" 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebColorName.h"
69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h"
70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h"
71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h" 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi er.h"
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h " 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h "
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 631 }
632 632
633 void RenderThreadImpl::IdleHandler() { 633 void RenderThreadImpl::IdleHandler() {
634 bool run_in_foreground_tab = (widget_count_ > hidden_widget_count_) && 634 bool run_in_foreground_tab = (widget_count_ > hidden_widget_count_) &&
635 content::GetContentClient()->renderer()-> 635 content::GetContentClient()->renderer()->
636 RunIdleHandlerWhenWidgetsHidden(); 636 RunIdleHandlerWhenWidgetsHidden();
637 if (run_in_foreground_tab) { 637 if (run_in_foreground_tab) {
638 IdleHandlerInForegroundTab(); 638 IdleHandlerInForegroundTab();
639 return; 639 return;
640 } 640 }
641 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 641
642 MallocExtension::instance()->ReleaseFreeMemory(); 642 base::allocator::ReleaseFreeMemory();
643 #endif
644 643
645 v8::V8::IdleNotification(); 644 v8::V8::IdleNotification();
646 645
647 // Schedule next invocation. 646 // Schedule next invocation.
648 // Dampen the delay using the algorithm (if delay is in seconds): 647 // Dampen the delay using the algorithm (if delay is in seconds):
649 // delay = delay + 1 / (delay + 2) 648 // delay = delay + 1 / (delay + 2)
650 // Using floor(delay) has a dampening effect such as: 649 // Using floor(delay) has a dampening effect such as:
651 // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ... 650 // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
652 // If the delay is in milliseconds, the above formula is equivalent to: 651 // If the delay is in milliseconds, the above formula is equivalent to:
653 // delay_ms / 1000 = delay_ms / 1000 + 1 / (delay_ms / 1000 + 2) 652 // delay_ms / 1000 = delay_ms / 1000 + 1 / (delay_ms / 1000 + 2)
(...skipping 17 matching lines...) Expand all
671 670
672 if (idle_notifications_to_skip_ > 0) { 671 if (idle_notifications_to_skip_ > 0) {
673 idle_notifications_to_skip_--; 672 idle_notifications_to_skip_--;
674 } else { 673 } else {
675 int cpu_usage = 0; 674 int cpu_usage = 0;
676 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage)); 675 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage));
677 // Idle notification hint roughly specifies the expected duration of the 676 // Idle notification hint roughly specifies the expected duration of the
678 // idle pause. We set it proportional to the idle timer delay. 677 // idle pause. We set it proportional to the idle timer delay.
679 int idle_hint = static_cast<int>(new_delay_ms / 10); 678 int idle_hint = static_cast<int>(new_delay_ms / 10);
680 if (cpu_usage < kIdleCPUUsageThresholdInPercents) { 679 if (cpu_usage < kIdleCPUUsageThresholdInPercents) {
681 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 680 base::allocator::ReleaseFreeMemory();
682 MallocExtension::instance()->ReleaseFreeMemory();
683 #endif
684 if (v8::V8::IdleNotification(idle_hint)) { 681 if (v8::V8::IdleNotification(idle_hint)) {
685 // V8 finished collecting garbage. 682 // V8 finished collecting garbage.
686 new_delay_ms = kLongIdleHandlerDelayMs; 683 new_delay_ms = kLongIdleHandlerDelayMs;
687 } 684 }
688 } 685 }
689 } 686 }
690 ScheduleIdleHandler(new_delay_ms); 687 ScheduleIdleHandler(new_delay_ms);
691 } 688 }
692 689
693 int64 RenderThreadImpl::GetIdleNotificationDelayInMs() const { 690 int64 RenderThreadImpl::GetIdleNotificationDelayInMs() const {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 1004
1008 scoped_refptr<base::MessageLoopProxy> 1005 scoped_refptr<base::MessageLoopProxy>
1009 RenderThreadImpl::GetFileThreadMessageLoopProxy() { 1006 RenderThreadImpl::GetFileThreadMessageLoopProxy() {
1010 DCHECK(message_loop() == MessageLoop::current()); 1007 DCHECK(message_loop() == MessageLoop::current());
1011 if (!file_thread_.get()) { 1008 if (!file_thread_.get()) {
1012 file_thread_.reset(new base::Thread("Renderer::FILE")); 1009 file_thread_.reset(new base::Thread("Renderer::FILE"));
1013 file_thread_->Start(); 1010 file_thread_->Start();
1014 } 1011 }
1015 return file_thread_->message_loop_proxy(); 1012 return file_thread_->message_loop_proxy();
1016 } 1013 }
OLDNEW
« no previous file with comments | « content/common/child_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698