| Index: cc/prioritized_resource_unittest.cc
 | 
| diff --git a/cc/prioritized_resource_unittest.cc b/cc/prioritized_resource_unittest.cc
 | 
| index 328d92c083022bd991a3aabbb6c44534586cf1b8..62552021d91a3daba8e9353a8b42b5de4232c550 100644
 | 
| --- a/cc/prioritized_resource_unittest.cc
 | 
| +++ b/cc/prioritized_resource_unittest.cc
 | 
| @@ -9,6 +9,7 @@
 | 
|  #include "cc/prioritized_resource_manager.h"
 | 
|  #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
 | 
|  #include "cc/test/fake_graphics_context.h"
 | 
| +#include "cc/test/fake_proxy.h"
 | 
|  #include "cc/test/tiled_layer_test_common.h"
 | 
|  #include "cc/texture.h"
 | 
|  #include "testing/gtest/include/gtest/gtest.h"
 | 
| @@ -21,17 +22,18 @@ namespace cc {
 | 
|  class PrioritizedResourceTest : public testing::Test {
 | 
|  public:
 | 
|      PrioritizedResourceTest()
 | 
| -        : m_textureSize(256, 256)
 | 
| +        : m_proxy(scoped_ptr<Thread>(NULL))
 | 
| +        , m_textureSize(256, 256)
 | 
|          , m_textureFormat(GL_RGBA)
 | 
|          , m_context(WebKit::createFakeGraphicsContext())
 | 
|      {
 | 
| -        DebugScopedSetImplThread implThread;
 | 
| +        DebugScopedSetImplThread implThread(&m_proxy);
 | 
|          m_resourceProvider = ResourceProvider::create(m_context.get());
 | 
|      }
 | 
|  
 | 
|      virtual ~PrioritizedResourceTest()
 | 
|      {
 | 
| -        DebugScopedSetImplThread implThread;
 | 
| +        DebugScopedSetImplThread implThread(&m_proxy);
 | 
|          m_resourceProvider.reset();
 | 
|      }
 | 
|  
 | 
| @@ -42,7 +44,7 @@ public:
 | 
|  
 | 
|      scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures)
 | 
|      {
 | 
| -        return PrioritizedResourceManager::create(texturesMemorySize(maxTextures), 1024, 0);
 | 
| +        return PrioritizedResourceManager::create(texturesMemorySize(maxTextures), 1024, 0, &m_proxy);
 | 
|      }
 | 
|  
 | 
|      bool validateTexture(scoped_ptr<PrioritizedResource>& texture, bool requestLate)
 | 
| @@ -51,7 +53,7 @@ public:
 | 
|          if (requestLate)
 | 
|              texture->requestLate();
 | 
|          resourceManagerAssertInvariants(texture->resourceManager());
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          bool success = texture->canAcquireBackingTexture();
 | 
|          if (success)
 | 
|              texture->acquireBackingTexture(resourceProvider());
 | 
| @@ -66,7 +68,7 @@ public:
 | 
|  
 | 
|      void resourceManagerUpdateBackingsPriorities(PrioritizedResourceManager* resourceManager)
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->pushTexturePrioritiesToBackings();
 | 
|      }
 | 
|  
 | 
| @@ -78,7 +80,7 @@ public:
 | 
|      void resourceManagerAssertInvariants(PrioritizedResourceManager* resourceManager)
 | 
|      {
 | 
|  #ifndef NDEBUG
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->assertInvariants();
 | 
|  #endif
 | 
|      }
 | 
| @@ -89,6 +91,7 @@ public:
 | 
|      }
 | 
|  
 | 
|  protected:
 | 
| +    FakeProxy m_proxy;
 | 
|      const gfx::Size m_textureSize;
 | 
|      const GLenum m_textureFormat;
 | 
|      scoped_ptr<GraphicsContext> m_context;
 | 
| @@ -135,7 +138,7 @@ TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit)
 | 
|      EXPECT_EQ(texturesMemorySize(maxTextures), resourceManager->memoryAboveCutoffBytes());
 | 
|      EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -156,7 +159,7 @@ TEST_F(PrioritizedResourceTest, changeMemoryLimits)
 | 
|      for (size_t i = 0; i < maxTextures; ++i)
 | 
|          validateTexture(textures[i], false);
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->reduceMemory(resourceProvider());
 | 
|      }
 | 
|  
 | 
| @@ -169,7 +172,7 @@ TEST_F(PrioritizedResourceTest, changeMemoryLimits)
 | 
|      for (size_t i = 0; i < maxTextures; ++i)
 | 
|          EXPECT_EQ(validateTexture(textures[i], false), i < 5);
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->reduceMemory(resourceProvider());
 | 
|      }
 | 
|  
 | 
| @@ -182,14 +185,14 @@ TEST_F(PrioritizedResourceTest, changeMemoryLimits)
 | 
|      for (size_t i = 0; i < maxTextures; ++i)
 | 
|          EXPECT_EQ(validateTexture(textures[i], false), i < 4);
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->reduceMemory(resourceProvider());
 | 
|      }
 | 
|  
 | 
|      EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
 | 
|      EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -213,7 +216,7 @@ TEST_F(PrioritizedResourceTest, changePriorityCutoff)
 | 
|      for (size_t i = 0; i < maxTextures; ++i)
 | 
|          EXPECT_EQ(validateTexture(textures[i], true), i < 6);
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->reduceMemory(resourceProvider());
 | 
|      }
 | 
|      EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes());
 | 
| @@ -225,7 +228,7 @@ TEST_F(PrioritizedResourceTest, changePriorityCutoff)
 | 
|      for (size_t i = 0; i < maxTextures; ++i)
 | 
|          EXPECT_EQ(validateTexture(textures[i], false), i < 4);
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->reduceMemory(resourceProvider());
 | 
|      }
 | 
|      EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
 | 
| @@ -233,7 +236,7 @@ TEST_F(PrioritizedResourceTest, changePriorityCutoff)
 | 
|      // Do a one-time eviction for one more texture based on priority cutoff
 | 
|      PrioritizedResourceManager::BackingList evictedBackings;
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, resourceProvider());
 | 
|          resourceManager->getEvictedBackings(evictedBackings);
 | 
|          EXPECT_EQ(0, evictedBackings.size());
 | 
| @@ -249,12 +252,12 @@ TEST_F(PrioritizedResourceTest, changePriorityCutoff)
 | 
|      for (size_t i = 0; i < maxTextures; ++i)
 | 
|          EXPECT_EQ(validateTexture(textures[i], false), i < 4);
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->reduceMemory(resourceProvider());
 | 
|      }
 | 
|      EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -314,7 +317,7 @@ TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures)
 | 
|      EXPECT_FALSE(textures[2]->haveBackingTexture());
 | 
|      EXPECT_FALSE(textures[3]->haveBackingTexture());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -354,7 +357,7 @@ TEST_F(PrioritizedResourceTest, resourceManagerPrioritiesAreEqual)
 | 
|      EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes());
 | 
|      EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -374,7 +377,7 @@ TEST_F(PrioritizedResourceTest, resourceManagerDestroyedFirst)
 | 
|      EXPECT_TRUE(texture->haveBackingTexture());
 | 
|  
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->clearAllMemory(resourceProvider());
 | 
|      }
 | 
|      resourceManager.reset();
 | 
| @@ -402,7 +405,7 @@ TEST_F(PrioritizedResourceTest, textureMovedToNewManager)
 | 
|      texture->setTextureManager(0);
 | 
|  
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManagerOne->clearAllMemory(resourceProvider());
 | 
|      }
 | 
|      resourceManagerOne.reset();
 | 
| @@ -418,7 +421,7 @@ TEST_F(PrioritizedResourceTest, textureMovedToNewManager)
 | 
|      EXPECT_TRUE(texture->canAcquireBackingTexture());
 | 
|      EXPECT_TRUE(texture->haveBackingTexture());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManagerTwo->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -464,7 +467,7 @@ TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableOutsideRootSu
 | 
|      EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextures());
 | 
|      EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -501,7 +504,7 @@ TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableForRequestLat
 | 
|      EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextures());
 | 
|      EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -541,7 +544,7 @@ TEST_F(PrioritizedResourceTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvai
 | 
|      EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryForSelfManagedTextures());
 | 
|      EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -589,7 +592,7 @@ TEST_F(PrioritizedResourceTest, requestLateBackingsSorting)
 | 
|      for (size_t i = 1; i < maxTextures; i += 2)
 | 
|          EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get()));
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| @@ -614,7 +617,7 @@ TEST_F(PrioritizedResourceTest, clearUploadsToEvictedResources)
 | 
|          EXPECT_TRUE(validateTexture(textures[i], false));
 | 
|  
 | 
|      ResourceUpdateQueue queue;
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      for (size_t i = 0; i < maxTextures; ++i) {
 | 
|          const ResourceUpdate upload = ResourceUpdate::Create(
 | 
|              textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d());
 | 
| @@ -666,7 +669,7 @@ TEST_F(PrioritizedResourceTest, usageStatistics)
 | 
|  
 | 
|      // Validate the statistics.
 | 
|      {
 | 
| -        DebugScopedSetImplThread implThread;
 | 
| +        DebugScopedSetImplThread implThread(&m_proxy);
 | 
|          EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
 | 
|          EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes());
 | 
|          EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearbyBytes());
 | 
| @@ -682,7 +685,7 @@ TEST_F(PrioritizedResourceTest, usageStatistics)
 | 
|  
 | 
|      // Verify that we still see the old values.
 | 
|      {
 | 
| -        DebugScopedSetImplThread implThread;
 | 
| +        DebugScopedSetImplThread implThread(&m_proxy);
 | 
|          EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
 | 
|          EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes());
 | 
|          EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearbyBytes());
 | 
| @@ -690,14 +693,14 @@ TEST_F(PrioritizedResourceTest, usageStatistics)
 | 
|  
 | 
|      // Push priorities to backings, and verify we see the new values.
 | 
|      {
 | 
| -        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +        DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|          resourceManager->pushTexturePrioritiesToBackings();
 | 
|          EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
 | 
|          EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes());
 | 
|          EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearbyBytes());
 | 
|      }
 | 
|  
 | 
| -    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
 | 
| +    DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
 | 
|      resourceManager->clearAllMemory(resourceProvider());
 | 
|  }
 | 
|  
 | 
| 
 |