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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 using blink::WebView; | 153 using blink::WebView; |
151 | 154 |
152 namespace content { | 155 namespace content { |
153 | 156 |
154 namespace { | 157 namespace { |
155 | 158 |
156 const int64 kInitialIdleHandlerDelayMs = 1000; | 159 const int64 kInitialIdleHandlerDelayMs = 1000; |
157 const int64 kShortIdleHandlerDelayMs = 1000; | 160 const int64 kShortIdleHandlerDelayMs = 1000; |
158 const int64 kLongIdleHandlerDelayMs = 30*1000; | 161 const int64 kLongIdleHandlerDelayMs = 30*1000; |
159 const int kIdleCPUUsageThresholdInPercents = 3; | 162 const int kIdleCPUUsageThresholdInPercents = 3; |
163 const int kMinRasterThreads = 1; | |
164 const int kMaxRasterThreads = 64; | |
160 | 165 |
161 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access | 166 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access |
162 // incorrectly from the wrong thread. | 167 // incorrectly from the wrong thread. |
163 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 168 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > |
164 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 169 lazy_tls = LAZY_INSTANCE_INITIALIZER; |
165 | 170 |
166 class RenderViewZoomer : public RenderViewVisitor { | 171 class RenderViewZoomer : public RenderViewVisitor { |
167 public: | 172 public: |
168 RenderViewZoomer(const std::string& scheme, | 173 RenderViewZoomer(const std::string& scheme, |
169 const std::string& host, | 174 const std::string& host, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 | 405 |
401 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 406 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
402 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); | 407 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); |
403 | 408 |
404 renderer_process_id_ = base::kNullProcessId; | 409 renderer_process_id_ = base::kNullProcessId; |
405 | 410 |
406 // AllocateGpuMemoryBuffer must be used exclusively on one thread but | 411 // AllocateGpuMemoryBuffer must be used exclusively on one thread but |
407 // it doesn't have to be the same thread RenderThreadImpl is created on. | 412 // it doesn't have to be the same thread RenderThreadImpl is created on. |
408 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); | 413 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); |
409 | 414 |
415 if (command_line.HasSwitch(cc::switches::kNumRasterThreads)) { | |
jamesr
2014/01/15 19:17:33
if this flag is only going to be used in content/
| |
416 int num_raster_threads; | |
417 std::string string_value = | |
418 command_line.GetSwitchValueASCII(cc::switches::kNumRasterThreads); | |
419 if (base::StringToInt(string_value, &num_raster_threads) && | |
420 num_raster_threads >= kMinRasterThreads && | |
421 num_raster_threads <= kMaxRasterThreads) { | |
422 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); | |
423 } else { | |
424 LOG(WARNING) << "Failed to parse switch " << | |
425 cc::switches::kNumRasterThreads << ": " << string_value; | |
426 } | |
427 } | |
428 | |
410 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 429 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
411 } | 430 } |
412 | 431 |
413 RenderThreadImpl::~RenderThreadImpl() { | 432 RenderThreadImpl::~RenderThreadImpl() { |
414 } | 433 } |
415 | 434 |
416 void RenderThreadImpl::Shutdown() { | 435 void RenderThreadImpl::Shutdown() { |
417 FOR_EACH_OBSERVER( | 436 FOR_EACH_OBSERVER( |
418 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 437 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
419 | 438 |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 if (!gamepad_shared_memory_reader_) | 1370 if (!gamepad_shared_memory_reader_) |
1352 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 1371 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); |
1353 gamepad_shared_memory_reader_->SampleGamepads(*data); | 1372 gamepad_shared_memory_reader_->SampleGamepads(*data); |
1354 } | 1373 } |
1355 | 1374 |
1356 base::ProcessId RenderThreadImpl::renderer_process_id() const { | 1375 base::ProcessId RenderThreadImpl::renderer_process_id() const { |
1357 return renderer_process_id_; | 1376 return renderer_process_id_; |
1358 } | 1377 } |
1359 | 1378 |
1360 } // namespace content | 1379 } // namespace content |
OLD | NEW |