cc: Move textureUploadFlushPeriod to TextureUploader.

This moves texture upload related flushing to the TextureUploader
class. This is a more appropriate place to handle this type of flushing
and makes it possible to avoid some unnecessary flushes.

BUG=
TEST=cc_unittests


Review URL: https://chromiumcodereview.appspot.com/11367054

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165860 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/resource_update_controller.cc b/cc/resource_update_controller.cc
index 5295724e..10c3b4d 100644
--- a/cc/resource_update_controller.cc
+++ b/cc/resource_update_controller.cc
@@ -32,9 +32,6 @@
 // Measured in seconds.
 const double uploaderBusyTickRate = 0.001;
 
-// Flush interval when performing texture uploads.
-const int textureUploadFlushPeriod = 4;
-
 // Number of blocking update intervals to allow.
 const size_t maxBlockingUpdateIntervals = 4;
 
@@ -193,25 +190,13 @@
 
 void ResourceUpdateController::finalize()
 {
-    size_t uploadCount = 0;
-    while (m_queue->fullUploadSize()) {
-        if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
-            m_resourceProvider->shallowFlushIfSupported();
-
+    while (m_queue->fullUploadSize())
         updateTexture(m_queue->takeFirstFullUpload());
-        uploadCount++;
-    }
 
-    while (m_queue->partialUploadSize()) {
-        if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
-            m_resourceProvider->shallowFlushIfSupported();
-
+    while (m_queue->partialUploadSize())
         updateTexture(m_queue->takeFirstPartialUpload());
-        uploadCount++;
-    }
 
-    if (uploadCount)
-        m_resourceProvider->shallowFlushIfSupported();
+    m_resourceProvider->flushUploads();
 
     if (m_queue->copySize()) {
         TextureCopier* copier = m_resourceProvider->textureCopier();
@@ -291,14 +276,10 @@
     if (!uploads)
         return;
 
-    size_t uploadCount = 0;
-    while (m_queue->fullUploadSize() && uploadCount < uploads) {
-        if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
-            m_resourceProvider->shallowFlushIfSupported();
+    while (m_queue->fullUploadSize() && uploads--)
         updateTexture(m_queue->takeFirstFullUpload());
-        uploadCount++;
-    }
-    m_resourceProvider->shallowFlushIfSupported();
+
+    m_resourceProvider->flushUploads();
 }
 
 }  // namespace cc