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> |
11 | 11 |
12 #include "base/allocator/allocator_extension.h" | 12 #include "base/allocator/allocator_extension.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/discardable_memory.h" | 17 #include "base/memory/discardable_memory.h" |
18 #include "base/memory/shared_memory.h" | 18 #include "base/memory/shared_memory.h" |
19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
21 #include "base/metrics/stats_table.h" | 21 #include "base/metrics/stats_table.h" |
22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
23 #include "base/strings/string16.h" | 23 #include "base/strings/string16.h" |
24 #include "base/strings/string_tokenizer.h" | 24 #include "base/strings/string_tokenizer.h" |
| 25 #include "base/strings/string_number_conversions.h" |
25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
26 #include "base/threading/thread_local.h" | 27 #include "base/threading/thread_local.h" |
27 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
28 #include "base/values.h" | 29 #include "base/values.h" |
29 #include "cc/base/switches.h" | 30 #include "cc/base/switches.h" |
| 31 #include "cc/resources/worker_pool.h" |
30 #include "content/child/appcache/appcache_dispatcher.h" | 32 #include "content/child/appcache/appcache_dispatcher.h" |
31 #include "content/child/appcache/appcache_frontend_impl.h" | 33 #include "content/child/appcache/appcache_frontend_impl.h" |
32 #include "content/child/child_histogram_message_filter.h" | 34 #include "content/child/child_histogram_message_filter.h" |
33 #include "content/child/db_message_filter.h" | 35 #include "content/child/db_message_filter.h" |
34 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 36 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
35 #include "content/child/indexed_db/indexed_db_message_filter.h" | 37 #include "content/child/indexed_db/indexed_db_message_filter.h" |
36 #include "content/child/npapi/npobject_util.h" | 38 #include "content/child/npapi/npobject_util.h" |
37 #include "content/child/plugin_messages.h" | 39 #include "content/child/plugin_messages.h" |
38 #include "content/child/resource_dispatcher.h" | 40 #include "content/child/resource_dispatcher.h" |
39 #include "content/child/runtime_features.h" | 41 #include "content/child/runtime_features.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 using blink::WebView; | 154 using blink::WebView; |
153 | 155 |
154 namespace content { | 156 namespace content { |
155 | 157 |
156 namespace { | 158 namespace { |
157 | 159 |
158 const int64 kInitialIdleHandlerDelayMs = 1000; | 160 const int64 kInitialIdleHandlerDelayMs = 1000; |
159 const int64 kShortIdleHandlerDelayMs = 1000; | 161 const int64 kShortIdleHandlerDelayMs = 1000; |
160 const int64 kLongIdleHandlerDelayMs = 30*1000; | 162 const int64 kLongIdleHandlerDelayMs = 30*1000; |
161 const int kIdleCPUUsageThresholdInPercents = 3; | 163 const int kIdleCPUUsageThresholdInPercents = 3; |
| 164 const int kMinRasterThreads = 1; |
| 165 const int kMaxRasterThreads = 64; |
162 | 166 |
163 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access | 167 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access |
164 // incorrectly from the wrong thread. | 168 // incorrectly from the wrong thread. |
165 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 169 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > |
166 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 170 lazy_tls = LAZY_INSTANCE_INITIALIZER; |
167 | 171 |
168 class RenderViewZoomer : public RenderViewVisitor { | 172 class RenderViewZoomer : public RenderViewVisitor { |
169 public: | 173 public: |
170 RenderViewZoomer(const std::string& scheme, | 174 RenderViewZoomer(const std::string& scheme, |
171 const std::string& host, | 175 const std::string& host, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 base::DiscardableMemory::SetPreferredType(type); | 435 base::DiscardableMemory::SetPreferredType(type); |
432 | 436 |
433 // Allow discardable memory implementations to register memory pressure | 437 // Allow discardable memory implementations to register memory pressure |
434 // listeners. | 438 // listeners. |
435 base::DiscardableMemory::RegisterMemoryPressureListeners(); | 439 base::DiscardableMemory::RegisterMemoryPressureListeners(); |
436 | 440 |
437 // AllocateGpuMemoryBuffer must be used exclusively on one thread but | 441 // AllocateGpuMemoryBuffer must be used exclusively on one thread but |
438 // it doesn't have to be the same thread RenderThreadImpl is created on. | 442 // it doesn't have to be the same thread RenderThreadImpl is created on. |
439 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); | 443 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); |
440 | 444 |
| 445 if (command_line.HasSwitch(cc::switches::kNumRasterThreads)) { |
| 446 int num_raster_threads; |
| 447 std::string string_value = |
| 448 command_line.GetSwitchValueASCII(cc::switches::kNumRasterThreads); |
| 449 if (base::StringToInt(string_value, &num_raster_threads) && |
| 450 num_raster_threads >= kMinRasterThreads && |
| 451 num_raster_threads <= kMaxRasterThreads) { |
| 452 cc::WorkerPool::SetNumRasterThreads(num_raster_threads); |
| 453 } else { |
| 454 LOG(WARNING) << "Failed to parse switch " << |
| 455 cc::switches::kNumRasterThreads << ": " << string_value; |
| 456 } |
| 457 } |
| 458 |
441 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 459 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
442 } | 460 } |
443 | 461 |
444 RenderThreadImpl::~RenderThreadImpl() { | 462 RenderThreadImpl::~RenderThreadImpl() { |
445 } | 463 } |
446 | 464 |
447 void RenderThreadImpl::Shutdown() { | 465 void RenderThreadImpl::Shutdown() { |
448 FOR_EACH_OBSERVER( | 466 FOR_EACH_OBSERVER( |
449 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 467 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
450 | 468 |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 hidden_widget_count_--; | 1419 hidden_widget_count_--; |
1402 | 1420 |
1403 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1421 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1404 return; | 1422 return; |
1405 } | 1423 } |
1406 | 1424 |
1407 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1425 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1408 } | 1426 } |
1409 | 1427 |
1410 } // namespace content | 1428 } // namespace content |
OLD | NEW |