OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/gpu/shader_disk_cache.h" | 5 #include "content/browser/gpu/shader_disk_cache.h" |
6 | 6 |
7 #include "base/threading/thread_checker.h" | 7 #include "base/threading/thread_checker.h" |
8 #include "content/browser/gpu/gpu_process_host.h" | 8 #include "content/browser/gpu/gpu_process_host.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "gpu/command_buffer/common/constants.h" | 10 #include "gpu/command_buffer/common/constants.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 void OnOpComplete(int rv); | 89 void OnOpComplete(int rv); |
90 | 90 |
91 int OpenNextEntry(); | 91 int OpenNextEntry(); |
92 int OpenNextEntryComplete(int rv); | 92 int OpenNextEntryComplete(int rv); |
93 int ReadComplete(int rv); | 93 int ReadComplete(int rv); |
94 int IterationComplete(int rv); | 94 int IterationComplete(int rv); |
95 | 95 |
96 base::WeakPtr<ShaderDiskCache> cache_; | 96 base::WeakPtr<ShaderDiskCache> cache_; |
97 OpType op_type_; | 97 OpType op_type_; |
98 scoped_ptr<disk_cache::Backend::Iterator> iter_; | 98 void* iter_; |
99 scoped_refptr<net::IOBufferWithSize> buf_; | 99 scoped_refptr<net::IOBufferWithSize> buf_; |
100 int host_id_; | 100 int host_id_; |
101 disk_cache::Entry* entry_; | 101 disk_cache::Entry* entry_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(ShaderDiskReadHelper); | 103 DISALLOW_COPY_AND_ASSIGN(ShaderDiskReadHelper); |
104 }; | 104 }; |
105 | 105 |
106 class ShaderClearHelper | 106 class ShaderClearHelper |
107 : public base::RefCounted<ShaderClearHelper>, | 107 : public base::RefCounted<ShaderClearHelper>, |
108 public base::SupportsWeakPtr<ShaderClearHelper> { | 108 public base::SupportsWeakPtr<ShaderClearHelper> { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 cache_->EntryComplete(this); | 236 cache_->EntryComplete(this); |
237 op_type_ = TERMINATE; | 237 op_type_ = TERMINATE; |
238 return rv; | 238 return rv; |
239 } | 239 } |
240 | 240 |
241 ShaderDiskReadHelper::ShaderDiskReadHelper( | 241 ShaderDiskReadHelper::ShaderDiskReadHelper( |
242 base::WeakPtr<ShaderDiskCache> cache, | 242 base::WeakPtr<ShaderDiskCache> cache, |
243 int host_id) | 243 int host_id) |
244 : cache_(cache), | 244 : cache_(cache), |
245 op_type_(OPEN_NEXT), | 245 op_type_(OPEN_NEXT), |
| 246 iter_(NULL), |
246 buf_(NULL), | 247 buf_(NULL), |
247 host_id_(host_id), | 248 host_id_(host_id), |
248 entry_(NULL) { | 249 entry_(NULL) { |
249 } | 250 } |
250 | 251 |
251 void ShaderDiskReadHelper::LoadCache() { | 252 void ShaderDiskReadHelper::LoadCache() { |
252 DCHECK(CalledOnValidThread()); | 253 DCHECK(CalledOnValidThread()); |
253 if (!cache_.get()) | 254 if (!cache_.get()) |
254 return; | 255 return; |
255 OnOpComplete(net::OK); | 256 OnOpComplete(net::OK); |
(...skipping 27 matching lines...) Expand all Loading... |
283 rv = net::ERR_FAILED; | 284 rv = net::ERR_FAILED; |
284 break; | 285 break; |
285 } | 286 } |
286 } while (rv != net::ERR_IO_PENDING); | 287 } while (rv != net::ERR_IO_PENDING); |
287 } | 288 } |
288 | 289 |
289 int ShaderDiskReadHelper::OpenNextEntry() { | 290 int ShaderDiskReadHelper::OpenNextEntry() { |
290 DCHECK(CalledOnValidThread()); | 291 DCHECK(CalledOnValidThread()); |
291 // Called through OnOpComplete, so we know |cache_| is valid. | 292 // Called through OnOpComplete, so we know |cache_| is valid. |
292 op_type_ = OPEN_NEXT_COMPLETE; | 293 op_type_ = OPEN_NEXT_COMPLETE; |
293 if (!iter_) | 294 return cache_->backend()->OpenNextEntry( |
294 iter_ = cache_->backend()->CreateIterator(); | 295 &iter_, |
295 return iter_->OpenNextEntry( | 296 &entry_, |
296 &entry_, base::Bind(&ShaderDiskReadHelper::OnOpComplete, this)); | 297 base::Bind(&ShaderDiskReadHelper::OnOpComplete, this)); |
297 } | 298 } |
298 | 299 |
299 int ShaderDiskReadHelper::OpenNextEntryComplete(int rv) { | 300 int ShaderDiskReadHelper::OpenNextEntryComplete(int rv) { |
300 DCHECK(CalledOnValidThread()); | 301 DCHECK(CalledOnValidThread()); |
301 // Called through OnOpComplete, so we know |cache_| is valid. | 302 // Called through OnOpComplete, so we know |cache_| is valid. |
302 if (rv == net::ERR_FAILED) { | 303 if (rv == net::ERR_FAILED) { |
303 op_type_ = ITERATION_FINISHED; | 304 op_type_ = ITERATION_FINISHED; |
304 return net::OK; | 305 return net::OK; |
305 } | 306 } |
306 | 307 |
(...skipping 24 matching lines...) Expand all Loading... |
331 entry_->Close(); | 332 entry_->Close(); |
332 entry_ = NULL; | 333 entry_ = NULL; |
333 | 334 |
334 op_type_ = OPEN_NEXT; | 335 op_type_ = OPEN_NEXT; |
335 return net::OK; | 336 return net::OK; |
336 } | 337 } |
337 | 338 |
338 int ShaderDiskReadHelper::IterationComplete(int rv) { | 339 int ShaderDiskReadHelper::IterationComplete(int rv) { |
339 DCHECK(CalledOnValidThread()); | 340 DCHECK(CalledOnValidThread()); |
340 // Called through OnOpComplete, so we know |cache_| is valid. | 341 // Called through OnOpComplete, so we know |cache_| is valid. |
341 iter_.reset(); | 342 cache_->backend()->EndEnumeration(&iter_); |
| 343 iter_ = NULL; |
342 op_type_ = TERMINATE; | 344 op_type_ = TERMINATE; |
343 return net::OK; | 345 return net::OK; |
344 } | 346 } |
345 | 347 |
346 ShaderDiskReadHelper::~ShaderDiskReadHelper() { | 348 ShaderDiskReadHelper::~ShaderDiskReadHelper() { |
347 if (entry_) | 349 if (entry_) |
348 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 350 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
349 base::Bind(&EntryCloser, entry_)); | 351 base::Bind(&EntryCloser, entry_)); |
350 } | 352 } |
351 | 353 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 const net::CompletionCallback& callback) { | 608 const net::CompletionCallback& callback) { |
607 if (entry_map_.empty()) { | 609 if (entry_map_.empty()) { |
608 return net::OK; | 610 return net::OK; |
609 } | 611 } |
610 cache_complete_callback_ = callback; | 612 cache_complete_callback_ = callback; |
611 return net::ERR_IO_PENDING; | 613 return net::ERR_IO_PENDING; |
612 } | 614 } |
613 | 615 |
614 } // namespace content | 616 } // namespace content |
615 | 617 |
OLD | NEW |