summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/jni/JavaSharedClient.cpp
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2012-01-09 15:11:01 -0800
committerGeorge Mount <mount@google.com>2012-01-13 14:19:28 -0800
commit58cd2bf639bfde23e323e6a519976a120ab79059 (patch)
tree83d18b004a34b072b3b8e4f406d119ac6a87dfd0 /Source/WebKit/android/jni/JavaSharedClient.cpp
parenteeda08b1ca4b27f46c54656a420ab69b8eec870c (diff)
downloadexternal_webkit-58cd2bf639bfde23e323e6a519976a120ab79059.zip
external_webkit-58cd2bf639bfde23e323e6a519976a120ab79059.tar.gz
external_webkit-58cd2bf639bfde23e323e6a519976a120ab79059.tar.bz2
Honor 50 millisecond cap for WebKit JavaScript execution.
Bug 5843118 WebKit provides a 50 millisecond cap for executing JavaScript to ensure that UI remains responsive by allowing recordContent in the WebViewCore thread to run. JavaSharedClient::ServiceFunctionPtr processes functions until they are all complete, circumventing the timeout. This CL processes only a single function and then schedules additional calls if any remaining calls exist. Change-Id: I3e013ceeb02da475e0b1e37e715598a2fe048b12
Diffstat (limited to 'Source/WebKit/android/jni/JavaSharedClient.cpp')
-rw-r--r--Source/WebKit/android/jni/JavaSharedClient.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/Source/WebKit/android/jni/JavaSharedClient.cpp b/Source/WebKit/android/jni/JavaSharedClient.cpp
index 4f40355..4d073c2 100644
--- a/Source/WebKit/android/jni/JavaSharedClient.cpp
+++ b/Source/WebKit/android/jni/JavaSharedClient.cpp
@@ -88,12 +88,12 @@ namespace android {
FileSystemClient* JavaSharedClient::gFileSystemClient = NULL;
///////////////////////////////////////////////////////////////////////////
-
+
struct FuncPtrRec {
void (*fProc)(void* payload);
void* fPayload;
};
-
+
static SkMutex gFuncPtrQMutex;
static SkDeque gFuncPtrQ(sizeof(FuncPtrRec));
@@ -105,33 +105,34 @@ namespace android {
FuncPtrRec* rec = (FuncPtrRec*)gFuncPtrQ.push_back();
rec->fProc = proc;
rec->fPayload = payload;
-
+
gFuncPtrQMutex.release();
-
+
gTimerClient->signalServiceFuncPtrQueue();
}
void JavaSharedClient::ServiceFunctionPtrQueue()
{
- for (;;) {
- void (*proc)(void*) = 0;
- void* payload = 0;
- const FuncPtrRec* rec;
-
- // we have to copy the proc/payload (if present). we do this so we
- // don't call the proc inside the mutex (possible deadlock!)
- gFuncPtrQMutex.acquire();
- rec = (const FuncPtrRec*)gFuncPtrQ.front();
- if (rec) {
- proc = rec->fProc;
- payload = rec->fPayload;
- gFuncPtrQ.pop_front();
- }
- gFuncPtrQMutex.release();
-
- if (!rec)
- break;
- proc(payload);
+ // Don't let execution block the WebViewCore thread for too long.
+ void (*proc)(void*) = 0;
+ void* payload = 0;
+ const FuncPtrRec* rec;
+
+ // we have to copy the proc/payload (if present). we do this so we
+ // don't call the proc inside the mutex (possible deadlock!)
+ gFuncPtrQMutex.acquire();
+ rec = (const FuncPtrRec*)gFuncPtrQ.front();
+ if (rec) {
+ proc = rec->fProc;
+ payload = rec->fPayload;
+ gFuncPtrQ.pop_front();
}
+ bool scheduleAdditionalCall = (gFuncPtrQ.count() > 0);
+ gFuncPtrQMutex.release();
+
+ if (rec)
+ proc(payload);
+ if (scheduleAdditionalCall)
+ gTimerClient->signalServiceFuncPtrQueue();
}
}