| Index: cc/layers/delegated_frame_resource_collection.h | 
| diff --git a/cc/layers/delegated_frame_resource_collection.h b/cc/layers/delegated_frame_resource_collection.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..754d4535ea72303d8b7911802267fea3ee2a89ed | 
| --- /dev/null | 
| +++ b/cc/layers/delegated_frame_resource_collection.h | 
| @@ -0,0 +1,69 @@ | 
| +// Copyright 2013 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ | 
| +#define CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ | 
| + | 
| +#include "base/containers/hash_tables.h" | 
| +#include "base/memory/ref_counted.h" | 
| +#include "base/threading/thread_checker.h" | 
| +#include "cc/base/cc_export.h" | 
| +#include "cc/resources/return_callback.h" | 
| +#include "cc/resources/returned_resource.h" | 
| +#include "cc/resources/transferable_resource.h" | 
| + | 
| +namespace cc { | 
| +class BlockingTaskRunner; | 
| + | 
| +class CC_EXPORT DelegatedFrameResourceCollectionClient { | 
| + public: | 
| +  // Called to inform the client that returned resources can be | 
| +  // grabbed off the DelegatedFrameResourceCollection. | 
| +  virtual void UnusedResourcesAreAvailable() = 0; | 
| +}; | 
| + | 
| +class CC_EXPORT DelegatedFrameResourceCollection | 
| +    : public base::RefCounted<DelegatedFrameResourceCollection> { | 
| + public: | 
| +  explicit DelegatedFrameResourceCollection(); | 
| + | 
| +  void SetClient(DelegatedFrameResourceCollectionClient* client); | 
| + | 
| +  void TakeUnusedResourcesForChildCompositor(ReturnedResourceArray* array); | 
| + | 
| +  // Methods for DelegatedFrameProvider. | 
| +  void RefResources(const TransferableResourceArray& resources); | 
| +  ReturnCallback GetReturnResourcesCallbackForImplThread(); | 
| +  void ReceivedResources(const TransferableResourceArray& resources); | 
| +  void ReturnResources(const ReturnedResourceArray& returned); | 
| + | 
| + private: | 
| +  friend base::RefCounted<DelegatedFrameResourceCollection>; | 
| +  ~DelegatedFrameResourceCollection(); | 
| + | 
| +  void UnrefResources(const ReturnedResourceArray& returned); | 
| +  void UnrefResourcesOnImplThread( | 
| +      scoped_refptr<BlockingTaskRunner> main_thread_runner, | 
| +      const ReturnedResourceArray& returned); | 
| + | 
| +  DelegatedFrameResourceCollectionClient* client_; | 
| +  scoped_refptr<BlockingTaskRunner> main_thread_runner_; | 
| + | 
| +  ReturnedResourceArray returned_resources_for_child_compositor_; | 
| + | 
| +  struct RefCount { | 
| +    int refs_to_return; | 
| +    int refs_to_wait_for; | 
| +  }; | 
| +  typedef base::hash_map<unsigned, RefCount> ResourceIdRefCountMap; | 
| +  ResourceIdRefCountMap resource_id_ref_count_map_; | 
| + | 
| +  base::ThreadChecker main_thread_checker_; | 
| + | 
| +  DISALLOW_COPY_AND_ASSIGN(DelegatedFrameResourceCollection); | 
| +}; | 
| + | 
| +}  // namespace cc | 
| + | 
| +#endif  // CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_ | 
|  |