| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_ | 5 #ifndef CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_ |
| 6 #define CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_ | 6 #define CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 virtual ~ResourceUpdateController(); | 41 virtual ~ResourceUpdateController(); |
| 42 | 42 |
| 43 // Discard uploads to textures that were evicted on the impl thread. | 43 // Discard uploads to textures that were evicted on the impl thread. |
| 44 void DiscardUploadsToEvictedResources(); | 44 void DiscardUploadsToEvictedResources(); |
| 45 | 45 |
| 46 void PerformMoreUpdates(base::TimeTicks time_limit); | 46 void PerformMoreUpdates(base::TimeTicks time_limit); |
| 47 void Finalize(); | 47 void Finalize(); |
| 48 | 48 |
| 49 | 49 |
| 50 // Virtual for testing. | 50 // Virtual for testing. |
| 51 virtual base::TimeTicks Now() const; | |
| 52 virtual base::TimeDelta UpdateMoreTexturesTime() const; | |
| 53 virtual size_t UpdateMoreTexturesSize() const; | 51 virtual size_t UpdateMoreTexturesSize() const; |
| 52 virtual base::TimeTicks UpdateMoreTexturesCompletionTime(); |
| 54 | 53 |
| 55 protected: | 54 protected: |
| 56 ResourceUpdateController(ResourceUpdateControllerClient* client, | 55 ResourceUpdateController(ResourceUpdateControllerClient* client, |
| 57 base::SingleThreadTaskRunner* task_runner, | 56 base::SingleThreadTaskRunner* task_runner, |
| 58 scoped_ptr<ResourceUpdateQueue> queue, | 57 scoped_ptr<ResourceUpdateQueue> queue, |
| 59 ResourceProvider* resource_provider); | 58 ResourceProvider* resource_provider); |
| 60 | 59 |
| 61 private: | 60 private: |
| 62 static size_t MaxFullUpdatesPerTick(ResourceProvider* resource_provider); | 61 static size_t MaxFullUpdatesPerTick(ResourceProvider* resource_provider); |
| 63 | 62 |
| 64 size_t MaxBlockingUpdates() const; | 63 size_t MaxBlockingUpdates() const; |
| 65 base::TimeDelta PendingUpdateTime() const; | |
| 66 | 64 |
| 67 void UpdateTexture(ResourceUpdate update); | 65 void UpdateTexture(ResourceUpdate update); |
| 68 | 66 |
| 69 // This returns true when there were textures left to update. | 67 // This returns true when there were textures left to update. |
| 70 bool UpdateMoreTexturesIfEnoughTimeRemaining(); | 68 bool UpdateMoreTexturesIfEnoughTimeRemaining(); |
| 71 void UpdateMoreTexturesNow(); | 69 void UpdateMoreTexturesNow(); |
| 72 void OnTimerFired(); | 70 void OnTimerFired(); |
| 73 | 71 |
| 74 ResourceUpdateControllerClient* client_; | 72 ResourceUpdateControllerClient* client_; |
| 75 scoped_ptr<ResourceUpdateQueue> queue_; | 73 scoped_ptr<ResourceUpdateQueue> queue_; |
| 76 bool contents_textures_purged_; | 74 bool contents_textures_purged_; |
| 77 ResourceProvider* resource_provider_; | 75 ResourceProvider* resource_provider_; |
| 78 base::TimeTicks time_limit_; | 76 base::TimeTicks time_limit_; |
| 79 size_t texture_updates_per_tick_; | 77 size_t texture_updates_per_tick_; |
| 80 bool first_update_attempt_; | 78 bool first_update_attempt_; |
| 81 base::SingleThreadTaskRunner* task_runner_; | 79 base::SingleThreadTaskRunner* task_runner_; |
| 82 bool task_posted_; | 80 bool task_posted_; |
| 83 base::WeakPtrFactory<ResourceUpdateController> weak_factory_; | 81 base::WeakPtrFactory<ResourceUpdateController> weak_factory_; |
| 84 | 82 |
| 85 DISALLOW_COPY_AND_ASSIGN(ResourceUpdateController); | 83 DISALLOW_COPY_AND_ASSIGN(ResourceUpdateController); |
| 86 }; | 84 }; |
| 87 | 85 |
| 88 } // namespace cc | 86 } // namespace cc |
| 89 | 87 |
| 90 #endif // CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_ | 88 #endif // CC_RESOURCES_RESOURCE_UPDATE_CONTROLLER_H_ |
| OLD | NEW |