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 14 matching lines...) Expand all Loading... |
25 #include "base/strings/string_tokenizer.h" | 25 #include "base/strings/string_tokenizer.h" |
26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
27 #include "base/threading/thread_local.h" | 27 #include "base/threading/thread_local.h" |
28 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
29 #include "base/values.h" | 29 #include "base/values.h" |
30 #include "cc/base/switches.h" | 30 #include "cc/base/switches.h" |
31 #include "cc/resources/raster_worker_pool.h" | 31 #include "cc/resources/raster_worker_pool.h" |
32 #include "content/child/appcache/appcache_dispatcher.h" | 32 #include "content/child/appcache/appcache_dispatcher.h" |
33 #include "content/child/appcache/appcache_frontend_impl.h" | 33 #include "content/child/appcache/appcache_frontend_impl.h" |
34 #include "content/child/child_histogram_message_filter.h" | 34 #include "content/child/child_histogram_message_filter.h" |
| 35 #include "content/child/content_child_helpers.h" |
35 #include "content/child/db_message_filter.h" | 36 #include "content/child/db_message_filter.h" |
36 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 37 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
37 #include "content/child/indexed_db/indexed_db_message_filter.h" | 38 #include "content/child/indexed_db/indexed_db_message_filter.h" |
38 #include "content/child/npapi/npobject_util.h" | 39 #include "content/child/npapi/npobject_util.h" |
39 #include "content/child/plugin_messages.h" | 40 #include "content/child/plugin_messages.h" |
40 #include "content/child/resource_dispatcher.h" | 41 #include "content/child/resource_dispatcher.h" |
41 #include "content/child/runtime_features.h" | 42 #include "content/child/runtime_features.h" |
42 #include "content/child/thread_safe_sender.h" | 43 #include "content/child/thread_safe_sender.h" |
43 #include "content/child/web_database_observer_impl.h" | 44 #include "content/child/web_database_observer_impl.h" |
44 #include "content/child/worker_task_runner.h" | 45 #include "content/child/worker_task_runner.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 286 |
286 virtual void OnConnectionError() OVERRIDE { delete this; } | 287 virtual void OnConnectionError() OVERRIDE { delete this; } |
287 }; | 288 }; |
288 | 289 |
289 void CreateRenderFrameSetup(mojo::InterfaceRequest<RenderFrameSetup> request) { | 290 void CreateRenderFrameSetup(mojo::InterfaceRequest<RenderFrameSetup> request) { |
290 mojo::BindToRequest(new RenderFrameSetupImpl(), &request); | 291 mojo::BindToRequest(new RenderFrameSetupImpl(), &request); |
291 } | 292 } |
292 | 293 |
293 } // namespace | 294 } // namespace |
294 | 295 |
| 296 // For measuring memory usage after each task. Behind a command line flag. |
| 297 class MemoryObserver : public base::MessageLoop::TaskObserver { |
| 298 public: |
| 299 MemoryObserver() {} |
| 300 virtual ~MemoryObserver() {} |
| 301 |
| 302 virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE { |
| 303 } |
| 304 |
| 305 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE { |
| 306 HISTOGRAM_MEMORY_KB("Memory.RendererUsed", GetMemoryUsageKB()); |
| 307 } |
| 308 |
| 309 private: |
| 310 DISALLOW_COPY_AND_ASSIGN(MemoryObserver); |
| 311 }; |
| 312 |
295 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { | 313 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { |
296 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); | 314 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); |
297 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); | 315 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); |
298 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); | 316 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); |
299 } | 317 } |
300 | 318 |
301 RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {} | 319 RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {} |
302 | 320 |
303 void RenderThreadImpl::HistogramCustomizer::RenderViewNavigatedToHost( | 321 void RenderThreadImpl::HistogramCustomizer::RenderViewNavigatedToHost( |
304 const std::string& host, size_t view_count) { | 322 const std::string& host, size_t view_count) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 mojo::CloseRaw(it->second); | 560 mojo::CloseRaw(it->second); |
543 } | 561 } |
544 } | 562 } |
545 | 563 |
546 void RenderThreadImpl::Shutdown() { | 564 void RenderThreadImpl::Shutdown() { |
547 FOR_EACH_OBSERVER( | 565 FOR_EACH_OBSERVER( |
548 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 566 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
549 | 567 |
550 ChildThread::Shutdown(); | 568 ChildThread::Shutdown(); |
551 | 569 |
| 570 if (memory_observer_) { |
| 571 message_loop()->RemoveTaskObserver(memory_observer_.get()); |
| 572 memory_observer_.reset(); |
| 573 } |
| 574 |
552 // Wait for all databases to be closed. | 575 // Wait for all databases to be closed. |
553 if (webkit_platform_support_) { | 576 if (webkit_platform_support_) { |
554 webkit_platform_support_->web_database_observer_impl()-> | 577 webkit_platform_support_->web_database_observer_impl()-> |
555 WaitForAllDatabasesToClose(); | 578 WaitForAllDatabasesToClose(); |
556 } | 579 } |
557 | 580 |
558 // Shutdown in reverse of the initialization order. | 581 // Shutdown in reverse of the initialization order. |
559 if (devtools_agent_message_filter_.get()) { | 582 if (devtools_agent_message_filter_.get()) { |
560 RemoveFilter(devtools_agent_message_filter_.get()); | 583 RemoveFilter(devtools_agent_message_filter_.get()); |
561 devtools_agent_message_filter_ = NULL; | 584 devtools_agent_message_filter_ = NULL; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) | 892 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) |
870 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 893 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
871 | 894 |
872 SetSharedMemoryAllocationFunction(AllocateSharedMemoryFunction); | 895 SetSharedMemoryAllocationFunction(AllocateSharedMemoryFunction); |
873 | 896 |
874 // Limit use of the scaled image cache to when deferred image decoding is | 897 // Limit use of the scaled image cache to when deferred image decoding is |
875 // enabled. | 898 // enabled. |
876 if (!command_line.HasSwitch(switches::kEnableDeferredImageDecoding) && | 899 if (!command_line.HasSwitch(switches::kEnableDeferredImageDecoding) && |
877 !is_impl_side_painting_enabled_) | 900 !is_impl_side_painting_enabled_) |
878 SkGraphics::SetImageCacheByteLimit(0u); | 901 SkGraphics::SetImageCacheByteLimit(0u); |
| 902 |
| 903 if (command_line.HasSwitch(switches::kMemoryMetrics)) { |
| 904 memory_observer_.reset(new MemoryObserver()); |
| 905 message_loop()->AddTaskObserver(memory_observer_.get()); |
| 906 } |
879 } | 907 } |
880 | 908 |
881 void RenderThreadImpl::RegisterSchemes() { | 909 void RenderThreadImpl::RegisterSchemes() { |
882 // swappedout: pages should not be accessible, and should also | 910 // swappedout: pages should not be accessible, and should also |
883 // be treated as empty documents that can commit synchronously. | 911 // be treated as empty documents that can commit synchronously. |
884 WebString swappedout_scheme(base::ASCIIToUTF16(kSwappedOutScheme)); | 912 WebString swappedout_scheme(base::ASCIIToUTF16(kSwappedOutScheme)); |
885 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme); | 913 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme); |
886 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme); | 914 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme); |
887 } | 915 } |
888 | 916 |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 hidden_widget_count_--; | 1608 hidden_widget_count_--; |
1581 | 1609 |
1582 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1610 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1583 return; | 1611 return; |
1584 } | 1612 } |
1585 | 1613 |
1586 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1614 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1587 } | 1615 } |
1588 | 1616 |
1589 } // namespace content | 1617 } // namespace content |
OLD | NEW |