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 = 0; |
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 parsed_num_raster_threads = |
564 num_raster_threads >= kMinRasterThreads && | 562 base::StringToInt(string_value, &num_raster_threads); |
565 num_raster_threads <= kMaxRasterThreads) { | 563 DCHECK(parsed_num_raster_threads) << string_value; |
566 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); | 564 DCHECK_GT(num_raster_threads, 0); |
567 } else { | 565 cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); |
568 LOG(WARNING) << "Failed to parse switch " << | |
569 switches::kNumRasterThreads << ": " << string_value; | |
570 } | |
571 } | 566 } |
572 | 567 |
573 service_registry()->AddService<RenderFrameSetup>( | 568 service_registry()->AddService<RenderFrameSetup>( |
574 base::Bind(CreateRenderFrameSetup)); | 569 base::Bind(CreateRenderFrameSetup)); |
575 | 570 |
576 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 571 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
577 } | 572 } |
578 | 573 |
579 RenderThreadImpl::~RenderThreadImpl() { | 574 RenderThreadImpl::~RenderThreadImpl() { |
580 for (std::map<int, mojo::MessagePipeHandle>::iterator it = | 575 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_--; | 1639 hidden_widget_count_--; |
1645 | 1640 |
1646 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1641 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1647 return; | 1642 return; |
1648 } | 1643 } |
1649 | 1644 |
1650 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1645 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1651 } | 1646 } |
1652 | 1647 |
1653 } // namespace content | 1648 } // namespace content |
OLD | NEW |