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" |
30 #include "cc/base/switches.h" | |
31 #include "cc/resources/raster_worker_pool.h" | |
29 #include "content/child/appcache/appcache_dispatcher.h" | 32 #include "content/child/appcache/appcache_dispatcher.h" |
30 #include "content/child/appcache/appcache_frontend_impl.h" | 33 #include "content/child/appcache/appcache_frontend_impl.h" |
31 #include "content/child/child_histogram_message_filter.h" | 34 #include "content/child/child_histogram_message_filter.h" |
32 #include "content/child/db_message_filter.h" | 35 #include "content/child/db_message_filter.h" |
33 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 36 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
34 #include "content/child/indexed_db/indexed_db_message_filter.h" | 37 #include "content/child/indexed_db/indexed_db_message_filter.h" |
35 #include "content/child/npapi/npobject_util.h" | 38 #include "content/child/npapi/npobject_util.h" |
36 #include "content/child/plugin_messages.h" | 39 #include "content/child/plugin_messages.h" |
37 #include "content/child/resource_dispatcher.h" | 40 #include "content/child/resource_dispatcher.h" |
38 #include "content/child/runtime_features.h" | 41 #include "content/child/runtime_features.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 #if defined(OS_ANDROID) | 135 #if defined(OS_ANDROID) |
133 #include <cpu-features.h> | 136 #include <cpu-features.h> |
134 #include "content/renderer/android/synchronous_compositor_factory.h" | 137 #include "content/renderer/android/synchronous_compositor_factory.h" |
135 #include "content/renderer/media/android/renderer_demuxer_android.h" | 138 #include "content/renderer/media/android/renderer_demuxer_android.h" |
136 #endif | 139 #endif |
137 | 140 |
138 #if defined(ENABLE_PLUGINS) | 141 #if defined(ENABLE_PLUGINS) |
139 #include "content/renderer/npapi/plugin_channel_host.h" | 142 #include "content/renderer/npapi/plugin_channel_host.h" |
140 #endif | 143 #endif |
141 | 144 |
145 | |
reveman
2014/01/06 20:01:35
we don't need this blank line
sohanjg
2014/01/07 08:35:23
Done.
| |
142 using base::ThreadRestrictions; | 146 using base::ThreadRestrictions; |
143 using blink::WebDocument; | 147 using blink::WebDocument; |
144 using blink::WebFrame; | 148 using blink::WebFrame; |
145 using blink::WebNetworkStateNotifier; | 149 using blink::WebNetworkStateNotifier; |
146 using blink::WebRuntimeFeatures; | 150 using blink::WebRuntimeFeatures; |
147 using blink::WebScriptController; | 151 using blink::WebScriptController; |
148 using blink::WebSecurityPolicy; | 152 using blink::WebSecurityPolicy; |
149 using blink::WebString; | 153 using blink::WebString; |
150 using blink::WebView; | 154 using blink::WebView; |
151 | 155 |
152 namespace content { | 156 namespace content { |
153 | 157 |
154 namespace { | 158 namespace { |
155 | 159 |
156 const int64 kInitialIdleHandlerDelayMs = 1000; | 160 const int64 kInitialIdleHandlerDelayMs = 1000; |
157 const int64 kShortIdleHandlerDelayMs = 1000; | 161 const int64 kShortIdleHandlerDelayMs = 1000; |
158 const int64 kLongIdleHandlerDelayMs = 30*1000; | 162 const int64 kLongIdleHandlerDelayMs = 30*1000; |
159 const int kIdleCPUUsageThresholdInPercents = 3; | 163 const int kIdleCPUUsageThresholdInPercents = 3; |
164 const int kMinRasterThreads = 1; | |
165 const int kMaxRasterThreads = 64; | |
166 const int kDefaultNumRasterThreads = 1; | |
160 | 167 |
161 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access | 168 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access |
162 // incorrectly from the wrong thread. | 169 // incorrectly from the wrong thread. |
163 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 170 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > |
164 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 171 lazy_tls = LAZY_INSTANCE_INITIALIZER; |
165 | 172 |
166 class RenderViewZoomer : public RenderViewVisitor { | 173 class RenderViewZoomer : public RenderViewVisitor { |
167 public: | 174 public: |
168 RenderViewZoomer(const std::string& scheme, | 175 RenderViewZoomer(const std::string& scheme, |
169 const std::string& host, | 176 const std::string& host, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 | 407 |
401 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 408 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
402 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); | 409 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); |
403 | 410 |
404 renderer_process_id_ = base::kNullProcessId; | 411 renderer_process_id_ = base::kNullProcessId; |
405 | 412 |
406 // AllocateGpuMemoryBuffer must be used exclusively on one thread but | 413 // AllocateGpuMemoryBuffer must be used exclusively on one thread but |
407 // it doesn't have to be the same thread RenderThreadImpl is created on. | 414 // it doesn't have to be the same thread RenderThreadImpl is created on. |
408 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); | 415 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); |
409 | 416 |
417 int num_raster_threads = kDefaultNumRasterThreads; | |
418 if (command_line.HasSwitch(cc::switches::kNumRasterThreads)) { | |
419 int num_threads; | |
420 std::string string_value = | |
421 command_line.GetSwitchValueASCII(cc::switches::kNumRasterThreads); | |
422 if (base::StringToInt(string_value, &num_threads) && | |
423 num_threads >= kMinRasterThreads && num_threads <= kMaxRasterThreads) | |
424 num_raster_threads = num_threads; | |
425 | |
426 LOG(WARNING) << "Failed to parse switch " << | |
427 cc::switches::kNumRasterThreads << ": " << string_value; | |
reveman
2014/01/06 20:01:35
you're always printing this warning. even when the
sohanjg
2014/01/07 08:35:23
Done.
| |
428 } | |
429 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); | |
430 | |
410 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 431 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
411 } | 432 } |
412 | 433 |
413 RenderThreadImpl::~RenderThreadImpl() { | 434 RenderThreadImpl::~RenderThreadImpl() { |
414 } | 435 } |
415 | 436 |
416 void RenderThreadImpl::Shutdown() { | 437 void RenderThreadImpl::Shutdown() { |
417 FOR_EACH_OBSERVER( | 438 FOR_EACH_OBSERVER( |
418 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 439 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
419 | 440 |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 if (!gamepad_shared_memory_reader_) | 1372 if (!gamepad_shared_memory_reader_) |
1352 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 1373 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); |
1353 gamepad_shared_memory_reader_->SampleGamepads(*data); | 1374 gamepad_shared_memory_reader_->SampleGamepads(*data); |
1354 } | 1375 } |
1355 | 1376 |
1356 base::ProcessId RenderThreadImpl::renderer_process_id() const { | 1377 base::ProcessId RenderThreadImpl::renderer_process_id() const { |
1357 return renderer_process_id_; | 1378 return renderer_process_id_; |
1358 } | 1379 } |
1359 | 1380 |
1360 } // namespace content | 1381 } // namespace content |
OLD | NEW |