Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1171)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 73923003: Shared Raster Worker Threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments + nits Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
vmpstr 2014/01/08 17:47:25 This appears here and in cc/resources/raster_worke
reveman 2014/01/08 18:07:56 I don't think cc should depend on this being alway
sohanjg 2014/01/09 07:25:32 Done.
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
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 }
425 else {
reveman 2014/01/08 07:06:40 nit: move "else {" to previous line
sohanjg 2014/01/09 07:25:32 Done.
426 LOG(WARNING) << "Failed to parse switch " <<
427 cc::switches::kNumRasterThreads << ": " << string_value;
428 }
429 }
430 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads);
431
410 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); 432 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, "");
411 } 433 }
412 434
413 RenderThreadImpl::~RenderThreadImpl() { 435 RenderThreadImpl::~RenderThreadImpl() {
414 } 436 }
415 437
416 void RenderThreadImpl::Shutdown() { 438 void RenderThreadImpl::Shutdown() {
417 FOR_EACH_OBSERVER( 439 FOR_EACH_OBSERVER(
418 RenderProcessObserver, observers_, OnRenderProcessShutdown()); 440 RenderProcessObserver, observers_, OnRenderProcessShutdown());
419 441
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 if (!gamepad_shared_memory_reader_) 1373 if (!gamepad_shared_memory_reader_)
1352 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); 1374 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
1353 gamepad_shared_memory_reader_->SampleGamepads(*data); 1375 gamepad_shared_memory_reader_->SampleGamepads(*data);
1354 } 1376 }
1355 1377
1356 base::ProcessId RenderThreadImpl::renderer_process_id() const { 1378 base::ProcessId RenderThreadImpl::renderer_process_id() const {
1357 return renderer_process_id_; 1379 return renderer_process_id_;
1358 } 1380 }
1359 1381
1360 } // namespace content 1382 } // namespace content
OLDNEW
« cc/resources/worker_pool.cc ('K') | « content/renderer/gpu/render_widget_compositor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698