Index: content/renderer/render_thread_impl.cc |
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc |
index 2914c9c299c19593c58243728a37e93c3b2b9ea4..3778f675059a898e21cdca4771e4e4ecc9e0f0d5 100644 |
--- a/content/renderer/render_thread_impl.cc |
+++ b/content/renderer/render_thread_impl.cc |
@@ -105,6 +105,7 @@ |
#include "content/renderer/render_view_impl.h" |
#include "content/renderer/renderer_blink_platform_impl.h" |
#include "content/renderer/scheduler/renderer_scheduler.h" |
+#include "content/renderer/scheduler/resource_dispatch_throttler.h" |
#include "content/renderer/service_worker/embedded_worker_context_message_filter.h" |
#include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
#include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
@@ -196,6 +197,16 @@ namespace { |
const int64 kInitialIdleHandlerDelayMs = 1000; |
const int64 kLongIdleHandlerDelayMs = 30*1000; |
+#if defined(OS_ANDROID) |
+// On Android, resource messages can each take ~1.5ms to dispatch on the browser |
+// IO thread. Limiting the message rate to 3/frame at 60hz ensures that the |
+// induced work takes but a fraction (~1/4) of the overall frame budget. |
+const int kMaxResourceRequestsPerFlushWhenThrottled = 3; |
+#else |
+const int kMaxResourceRequestsPerFlushWhenThrottled = 8; |
+#endif |
+const double kThrottledResourceRequestFlushPeriodS = 1. / 60.; |
+ |
// Maximum allocation size allowed for image scaling filters that |
// require pre-scaling. Skia will fallback to a filter that doesn't |
// require pre-scaling if the default filter would require an |
@@ -475,6 +486,12 @@ void RenderThreadImpl::Init() { |
channel()->SetListenerTaskRunner(renderer_scheduler_->DefaultTaskRunner()); |
embedded_worker_dispatcher_.reset(new EmbeddedWorkerDispatcher()); |
davidben
2015/02/03 19:46:47
Could you add a comment here, something like:
//
jdduke (slow)
2015/02/04 01:39:50
Done.
|
+ resource_dispatch_throttler_.reset(new ResourceDispatchThrottler( |
+ static_cast<RenderThread*>(this), renderer_scheduler_.get(), |
+ base::TimeDelta::FromSecondsD(kThrottledResourceRequestFlushPeriodS), |
+ kMaxResourceRequestsPerFlushWhenThrottled)); |
+ resource_dispatcher()->set_message_sender(resource_dispatch_throttler_.get()); |
+ |
media_stream_center_ = NULL; |
db_message_filter_ = new DBMessageFilter(); |