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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 namespace { | 166 namespace { |
167 | 167 |
168 const int64 kInitialIdleHandlerDelayMs = 1000; | 168 const int64 kInitialIdleHandlerDelayMs = 1000; |
169 const int64 kShortIdleHandlerDelayMs = 1000; | 169 const int64 kShortIdleHandlerDelayMs = 1000; |
170 const int64 kLongIdleHandlerDelayMs = 30*1000; | 170 const int64 kLongIdleHandlerDelayMs = 30*1000; |
171 const int kIdleCPUUsageThresholdInPercents = 3; | 171 const int kIdleCPUUsageThresholdInPercents = 3; |
172 const int kMinRasterThreads = 1; | 172 const int kMinRasterThreads = 1; |
173 const int kMaxRasterThreads = 64; | 173 const int kMaxRasterThreads = 64; |
174 | 174 |
| 175 // Maximum allocation size allowed for image scaling filters that |
| 176 // require pre-scaling. Skia will fallback to a filter that doesn't |
| 177 // require pre-scaling if the default filter would require an |
| 178 // allocation that exceeds this limit. |
| 179 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024; |
| 180 |
175 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access | 181 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access |
176 // incorrectly from the wrong thread. | 182 // incorrectly from the wrong thread. |
177 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 183 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > |
178 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 184 lazy_tls = LAZY_INSTANCE_INITIALIZER; |
179 | 185 |
180 class RenderViewZoomer : public RenderViewVisitor { | 186 class RenderViewZoomer : public RenderViewVisitor { |
181 public: | 187 public: |
182 RenderViewZoomer(const std::string& scheme, | 188 RenderViewZoomer(const std::string& scheme, |
183 const std::string& host, | 189 const std::string& host, |
184 double zoom_level) : scheme_(scheme), | 190 double zoom_level) : scheme_(scheme), |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 899 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
894 | 900 |
895 SetSharedMemoryAllocationFunction(AllocateSharedMemoryFunction); | 901 SetSharedMemoryAllocationFunction(AllocateSharedMemoryFunction); |
896 | 902 |
897 // Limit use of the scaled image cache to when deferred image decoding is | 903 // Limit use of the scaled image cache to when deferred image decoding is |
898 // enabled. | 904 // enabled. |
899 if (!command_line.HasSwitch(switches::kEnableDeferredImageDecoding) && | 905 if (!command_line.HasSwitch(switches::kEnableDeferredImageDecoding) && |
900 !is_impl_side_painting_enabled_) | 906 !is_impl_side_painting_enabled_) |
901 SkGraphics::SetImageCacheByteLimit(0u); | 907 SkGraphics::SetImageCacheByteLimit(0u); |
902 | 908 |
| 909 SkGraphics::SetImageCacheSingleAllocationByteLimit( |
| 910 kImageCacheSingleAllocationByteLimit); |
| 911 |
903 if (command_line.HasSwitch(switches::kMemoryMetrics)) { | 912 if (command_line.HasSwitch(switches::kMemoryMetrics)) { |
904 memory_observer_.reset(new MemoryObserver()); | 913 memory_observer_.reset(new MemoryObserver()); |
905 message_loop()->AddTaskObserver(memory_observer_.get()); | 914 message_loop()->AddTaskObserver(memory_observer_.get()); |
906 } | 915 } |
907 } | 916 } |
908 | 917 |
909 void RenderThreadImpl::RegisterSchemes() { | 918 void RenderThreadImpl::RegisterSchemes() { |
910 // swappedout: pages should not be accessible, and should also | 919 // swappedout: pages should not be accessible, and should also |
911 // be treated as empty documents that can commit synchronously. | 920 // be treated as empty documents that can commit synchronously. |
912 WebString swappedout_scheme(base::ASCIIToUTF16(kSwappedOutScheme)); | 921 WebString swappedout_scheme(base::ASCIIToUTF16(kSwappedOutScheme)); |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 hidden_widget_count_--; | 1617 hidden_widget_count_--; |
1609 | 1618 |
1610 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1619 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1611 return; | 1620 return; |
1612 } | 1621 } |
1613 | 1622 |
1614 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1623 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1615 } | 1624 } |
1616 | 1625 |
1617 } // namespace content | 1626 } // namespace content |
OLD | NEW |