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> |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 using blink::WebView; | 166 using blink::WebView; |
167 | 167 |
168 namespace content { | 168 namespace content { |
169 | 169 |
170 namespace { | 170 namespace { |
171 | 171 |
172 const int64 kInitialIdleHandlerDelayMs = 1000; | 172 const int64 kInitialIdleHandlerDelayMs = 1000; |
173 const int64 kShortIdleHandlerDelayMs = 1000; | 173 const int64 kShortIdleHandlerDelayMs = 1000; |
174 const int64 kLongIdleHandlerDelayMs = 30*1000; | 174 const int64 kLongIdleHandlerDelayMs = 30*1000; |
175 const int kIdleCPUUsageThresholdInPercents = 3; | 175 const int kIdleCPUUsageThresholdInPercents = 3; |
176 const int kMinRasterThreads = 1; | |
177 const int kMaxRasterThreads = 64; | |
178 | 176 |
179 // Maximum allocation size allowed for image scaling filters that | 177 // Maximum allocation size allowed for image scaling filters that |
180 // require pre-scaling. Skia will fallback to a filter that doesn't | 178 // require pre-scaling. Skia will fallback to a filter that doesn't |
181 // require pre-scaling if the default filter would require an | 179 // require pre-scaling if the default filter would require an |
182 // allocation that exceeds this limit. | 180 // allocation that exceeds this limit. |
183 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024; | 181 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024; |
184 | 182 |
185 const size_t kEmulatedDiscardableMemoryBytesToKeepWhenWidgetsHidden = | 183 const size_t kEmulatedDiscardableMemoryBytesToKeepWhenWidgetsHidden = |
186 4 * 1024 * 1024; | 184 4 * 1024 * 1024; |
187 | 185 |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 LOG(ERROR) << "Requested discardable memory type is not supported."; | 547 LOG(ERROR) << "Requested discardable memory type is not supported."; |
550 } | 548 } |
551 } | 549 } |
552 | 550 |
553 base::DiscardableMemory::SetPreferredType(type); | 551 base::DiscardableMemory::SetPreferredType(type); |
554 | 552 |
555 // AllocateGpuMemoryBuffer must be used exclusively on one thread but | 553 // AllocateGpuMemoryBuffer must be used exclusively on one thread but |
556 // it doesn't have to be the same thread RenderThreadImpl is created on. | 554 // it doesn't have to be the same thread RenderThreadImpl is created on. |
557 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); | 555 allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); |
558 | 556 |
559 if (command_line.HasSwitch(switches::kNumRasterThreads)) { | 557 if (is_impl_side_painting_enabled_) { |
560 int num_raster_threads; | 558 int num_raster_threads; |
jamesr
2014/08/29 19:50:39
initialize this var, please. if the StringToInt ca
danakj
2014/08/29 19:53:31
Done.
| |
561 std::string string_value = | 559 std::string string_value = |
562 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); | 560 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
563 if (base::StringToInt(string_value, &num_raster_threads) && | 561 bool ok = base::StringToInt(string_value, &num_raster_threads); |
564 num_raster_threads >= kMinRasterThreads && | 562 DCHECK(ok) << string_value; |
jamesr
2014/08/29 19:50:38
if you give this var a better name the error messa
danakj
2014/08/29 19:53:31
Done.
| |
565 num_raster_threads <= kMaxRasterThreads) { | 563 DCHECK_GT(num_raster_threads, 0); |
566 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); | 564 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); |
567 } else { | |
568 LOG(WARNING) << "Failed to parse switch " << | |
569 switches::kNumRasterThreads << ": " << string_value; | |
570 } | |
571 } | 565 } |
572 | 566 |
573 service_registry()->AddService<RenderFrameSetup>( | 567 service_registry()->AddService<RenderFrameSetup>( |
574 base::Bind(CreateRenderFrameSetup)); | 568 base::Bind(CreateRenderFrameSetup)); |
575 | 569 |
576 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 570 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
577 } | 571 } |
578 | 572 |
579 RenderThreadImpl::~RenderThreadImpl() { | 573 RenderThreadImpl::~RenderThreadImpl() { |
580 for (std::map<int, mojo::MessagePipeHandle>::iterator it = | 574 for (std::map<int, mojo::MessagePipeHandle>::iterator it = |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1644 hidden_widget_count_--; | 1638 hidden_widget_count_--; |
1645 | 1639 |
1646 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1640 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1647 return; | 1641 return; |
1648 } | 1642 } |
1649 | 1643 |
1650 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1644 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1651 } | 1645 } |
1652 | 1646 |
1653 } // namespace content | 1647 } // namespace content |
OLD | NEW |