OSDN Git Service

Ask the plugin how long to wait before calling NPN_WriteReady() again.
authorAndrei Popescu <andreip@google.com>
Tue, 30 Mar 2010 15:10:16 +0000 (16:10 +0100)
committerAndrei Popescu <andreip@google.com>
Tue, 30 Mar 2010 15:36:04 +0000 (16:36 +0100)
Change-Id: I46b25a5869e91e0075913caca5e57380f72f6107

WebCore/bridge/npapi.h
WebCore/plugins/PluginStream.cpp
WebCore/plugins/PluginStream.h

index 41f9bda..f0690b9 100644 (file)
@@ -374,8 +374,13 @@ typedef enum {
     NPPVpluginCoreAnimationLayer = 1003
 #endif
 
-#ifdef ANDROID
-    // TODO(andreip): Remove?
+#if PLATFORM(ANDROID)
+    /* Used when the plugin returns 0 from NPN_WriteReady and wishes the browser
+     * to wait a certain amount of millis before calling NPN_WriteReady again.
+     */
+    NPPDataDeliveryDelayMs = 100,
+
+    // TODO(reed): upstream
     NPPFakeValueToForce32Bits = 0x7FFFFFFF
 #endif
 } NPPVariable;
index 1e91c51..0f60fe3 100644 (file)
@@ -349,8 +349,13 @@ void PluginStream::deliverData()
 // TODO: This needs to be upstreamed.
             if (m_loader)
                 m_loader->pauseLoad(true);
-#endif
+
+            // ask the plugin for a delay value.
+            int delay = deliveryDelay();
+            m_delayDeliveryTimer.startOneShot(delay);
+#else
             m_delayDeliveryTimer.startOneShot(0);
+#endif
             break;
         } else {
             deliveryBytes = min(deliveryBytes, totalBytes - totalBytesDelivered);
@@ -485,4 +490,18 @@ bool PluginStream::wantsAllStreams() const
     return result != 0;
 }
 
+#if PLATFORM(ANDROID)
+int PluginStream::deliveryDelay() const
+{
+    if (!m_pluginFuncs->getvalue)
+        return 0;
+
+    int delay = 0;
+    if (m_pluginFuncs->getvalue(m_instance, NPPDataDeliveryDelayMs, &delay) != NPERR_NO_ERROR)
+        return 0;
+
+    return delay;
+}
+#endif
+
 }
index dc08f01..29a2644 100644 (file)
@@ -88,7 +88,9 @@ namespace WebCore {
         void deliverData();
         void destroyStream(NPReason);
         void destroyStream();
-
+#if PLATFORM(ANDROID)
+        int deliveryDelay() const;
+#endif
         ResourceRequest m_resourceRequest;
         ResourceResponse m_resourceResponse;