Update EnsureProcessGetsReaped to receive a pid.
[chromium-blink-merge.git] / cc / layers / delegated_frame_resource_collection.h
blobafbc3555a94d7118c904bf24e477cc7ec19f42ea
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_
6 #define CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_
8 #include "base/containers/hash_tables.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "cc/base/cc_export.h"
13 #include "cc/resources/return_callback.h"
14 #include "cc/resources/returned_resource.h"
15 #include "cc/resources/transferable_resource.h"
17 namespace cc {
19 class CC_EXPORT DelegatedFrameResourceCollectionClient {
20 public:
21 // Called to inform the client that returned resources can be
22 // grabbed off the DelegatedFrameResourceCollection.
23 virtual void UnusedResourcesAreAvailable() = 0;
26 class CC_EXPORT DelegatedFrameResourceCollection
27 : public base::RefCounted<DelegatedFrameResourceCollection> {
28 public:
29 DelegatedFrameResourceCollection();
31 void SetClient(DelegatedFrameResourceCollectionClient* client);
33 void TakeUnusedResourcesForChildCompositor(ReturnedResourceArray* array);
35 // Considers all resources as lost, and returns true if it held any resource
36 // to lose.
37 bool LoseAllResources();
39 // Methods for DelegatedFrameProvider.
40 void RefResources(const TransferableResourceArray& resources);
41 void UnrefResources(const ReturnedResourceArray& returned);
42 void ReceivedResources(const TransferableResourceArray& resources);
43 ReturnCallback GetReturnResourcesCallbackForImplThread();
45 private:
46 friend class base::RefCounted<DelegatedFrameResourceCollection>;
47 ~DelegatedFrameResourceCollection();
49 DelegatedFrameResourceCollectionClient* client_;
51 ReturnedResourceArray returned_resources_for_child_compositor_;
52 bool lost_all_resources_;
54 struct RefCount {
55 int refs_to_return;
56 int refs_to_wait_for;
58 typedef base::hash_map<unsigned, RefCount> ResourceIdRefCountMap;
59 ResourceIdRefCountMap resource_id_ref_count_map_;
61 base::ThreadChecker main_thread_checker_;
62 base::WeakPtrFactory<DelegatedFrameResourceCollection> weak_ptr_factory_;
64 DISALLOW_COPY_AND_ASSIGN(DelegatedFrameResourceCollection);
67 } // namespace cc
69 #endif // CC_LAYERS_DELEGATED_FRAME_RESOURCE_COLLECTION_H_