 Chromium Code Reviews
 Chromium Code Reviews Issue 73923003:
  Shared Raster Worker Threads  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 73923003:
  Shared Raster Worker Threads  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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; | |
| 165 const int kDefaultNumRasterThreads = 1; | |
| 160 | 166 | 
| 161 // 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 | 
| 162 // incorrectly from the wrong thread. | 168 // incorrectly from the wrong thread. | 
| 163 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 169 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 
| 164 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 170 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 
| 165 | 171 | 
| 166 class RenderViewZoomer : public RenderViewVisitor { | 172 class RenderViewZoomer : public RenderViewVisitor { | 
| 167 public: | 173 public: | 
| 168 RenderViewZoomer(const std::string& scheme, | 174 RenderViewZoomer(const std::string& scheme, | 
| 169 const std::string& host, | 175 const std::string& host, | 
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 | 406 | 
| 401 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 407 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 
| 402 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); | 408 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); | 
| 403 | 409 | 
| 404 renderer_process_id_ = base::kNullProcessId; | 410 renderer_process_id_ = base::kNullProcessId; | 
| 405 | 411 | 
| 406 // AllocateGpuMemoryBuffer must be used exclusively on one thread but | 412 // AllocateGpuMemoryBuffer must be used exclusively on one thread but | 
| 407 // it doesn't have to be the same thread RenderThreadImpl is created on. | 413 // it doesn't have to be the same thread RenderThreadImpl is created on. | 
| 408 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); | 414 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); | 
| 409 | 415 | 
| 416 int num_raster_threads = kDefaultNumRasterThreads; | |
| 417 if (command_line.HasSwitch(cc::switches::kNumRasterThreads)) { | |
| 418 int num_threads; | |
| 419 std::string string_value = | |
| 420 command_line.GetSwitchValueASCII(cc::switches::kNumRasterThreads); | |
| 421 if (base::StringToInt(string_value, &num_threads) && | |
| 422 num_threads >= kMinRasterThreads && num_threads <= kMaxRasterThreads) | |
| 423 num_raster_threads = num_threads; | |
| 424 else | |
| 425 LOG(WARNING) << "Failed to parse switch " << | |
| 426 cc::switches::kNumRasterThreads << ": " << string_value; | |
| 
reveman
2014/01/07 17:24:06
nit: multiple line "else". please use "{" "}" for
 
sohanjg
2014/01/08 05:55:43
Done.
 | |
| 427 } | |
| 428 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); | |
| 429 | |
| 410 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 430 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 
| 411 } | 431 } | 
| 412 | 432 | 
| 413 RenderThreadImpl::~RenderThreadImpl() { | 433 RenderThreadImpl::~RenderThreadImpl() { | 
| 414 } | 434 } | 
| 415 | 435 | 
| 416 void RenderThreadImpl::Shutdown() { | 436 void RenderThreadImpl::Shutdown() { | 
| 417 FOR_EACH_OBSERVER( | 437 FOR_EACH_OBSERVER( | 
| 418 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 438 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 
| 419 | 439 | 
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1351 if (!gamepad_shared_memory_reader_) | 1371 if (!gamepad_shared_memory_reader_) | 
| 1352 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 1372 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 
| 1353 gamepad_shared_memory_reader_->SampleGamepads(*data); | 1373 gamepad_shared_memory_reader_->SampleGamepads(*data); | 
| 1354 } | 1374 } | 
| 1355 | 1375 | 
| 1356 base::ProcessId RenderThreadImpl::renderer_process_id() const { | 1376 base::ProcessId RenderThreadImpl::renderer_process_id() const { | 
| 1357 return renderer_process_id_; | 1377 return renderer_process_id_; | 
| 1358 } | 1378 } | 
| 1359 | 1379 | 
| 1360 } // namespace content | 1380 } // namespace content | 
| OLD | NEW |