OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "cc/layers/delegated_frame_resource_collection.h" | 5 #include "cc/layers/delegated_frame_resource_collection.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "cc/trees/blocking_task_runner.h" | 8 #include "cc/trees/blocking_task_runner.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 | 11 |
12 DelegatedFrameResourceCollection::DelegatedFrameResourceCollection() | 12 DelegatedFrameResourceCollection::DelegatedFrameResourceCollection() |
13 : client_(NULL), | 13 : client_(NULL), |
14 main_thread_runner_(BlockingTaskRunner::current()), | |
15 lost_all_resources_(false), | 14 lost_all_resources_(false), |
16 weak_ptr_factory_(this) { | 15 weak_ptr_factory_(this) { |
17 DCHECK(main_thread_checker_.CalledOnValidThread()); | 16 DCHECK(main_thread_checker_.CalledOnValidThread()); |
18 } | 17 } |
19 | 18 |
20 DelegatedFrameResourceCollection::~DelegatedFrameResourceCollection() { | 19 DelegatedFrameResourceCollection::~DelegatedFrameResourceCollection() { |
21 DCHECK(main_thread_checker_.CalledOnValidThread()); | 20 DCHECK(main_thread_checker_.CalledOnValidThread()); |
22 } | 21 } |
23 | 22 |
24 void DelegatedFrameResourceCollection::SetClient( | 23 void DelegatedFrameResourceCollection::SetClient( |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 107 |
109 void DelegatedFrameResourceCollection::RefResources( | 108 void DelegatedFrameResourceCollection::RefResources( |
110 const TransferableResourceArray& resources) { | 109 const TransferableResourceArray& resources) { |
111 DCHECK(main_thread_checker_.CalledOnValidThread()); | 110 DCHECK(main_thread_checker_.CalledOnValidThread()); |
112 for (size_t i = 0; i < resources.size(); ++i) | 111 for (size_t i = 0; i < resources.size(); ++i) |
113 resource_id_ref_count_map_[resources[i].id].refs_to_wait_for++; | 112 resource_id_ref_count_map_[resources[i].id].refs_to_wait_for++; |
114 } | 113 } |
115 | 114 |
116 static void UnrefResourcesOnImplThread( | 115 static void UnrefResourcesOnImplThread( |
117 base::WeakPtr<DelegatedFrameResourceCollection> self, | 116 base::WeakPtr<DelegatedFrameResourceCollection> self, |
118 scoped_refptr<BlockingTaskRunner> main_thread_runner, | 117 const ReturnedResourceArray& returned, |
119 const ReturnedResourceArray& returned) { | 118 BlockingTaskRunner* main_thread_task_runner) { |
120 main_thread_runner->PostTask( | 119 main_thread_task_runner->PostTask( |
121 FROM_HERE, | 120 FROM_HERE, |
122 base::Bind( | 121 base::Bind( |
123 &DelegatedFrameResourceCollection::UnrefResources, self, returned)); | 122 &DelegatedFrameResourceCollection::UnrefResources, self, returned)); |
124 } | 123 } |
125 | 124 |
126 ReturnCallback | 125 ReturnCallback |
127 DelegatedFrameResourceCollection::GetReturnResourcesCallbackForImplThread() { | 126 DelegatedFrameResourceCollection::GetReturnResourcesCallbackForImplThread() { |
128 return base::Bind(&UnrefResourcesOnImplThread, | 127 return base::Bind(&UnrefResourcesOnImplThread, |
129 weak_ptr_factory_.GetWeakPtr(), | 128 weak_ptr_factory_.GetWeakPtr()); |
130 main_thread_runner_); | |
131 } | 129 } |
132 | 130 |
133 } // namespace cc | 131 } // namespace cc |
OLD | NEW |