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 "net/base/cache_type.h" | 10 #include "net/base/cache_type.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // Called through OnOpComplete, so we know |cache_| is valid. | 211 // Called through OnOpComplete, so we know |cache_| is valid. |
212 if (rv != net::OK) { | 212 if (rv != net::OK) { |
213 LOG(ERROR) << "Failed to create shader cache entry: " << rv; | 213 LOG(ERROR) << "Failed to create shader cache entry: " << rv; |
214 cache_->EntryComplete(this); | 214 cache_->EntryComplete(this); |
215 op_type_ = TERMINATE; | 215 op_type_ = TERMINATE; |
216 return rv; | 216 return rv; |
217 } | 217 } |
218 | 218 |
219 op_type_ = WRITE_DATA; | 219 op_type_ = WRITE_DATA; |
220 scoped_refptr<net::StringIOBuffer> io_buf = new net::StringIOBuffer(shader_); | 220 scoped_refptr<net::StringIOBuffer> io_buf = new net::StringIOBuffer(shader_); |
221 return entry_->WriteData(1, 0, io_buf, shader_.length(), | 221 return entry_->WriteData( |
222 base::Bind(&ShaderDiskCacheEntry::OnOpComplete, | 222 1, |
223 this), | 223 0, |
224 false); | 224 io_buf.get(), |
| 225 shader_.length(), |
| 226 base::Bind(&ShaderDiskCacheEntry::OnOpComplete, this), |
| 227 false); |
225 } | 228 } |
226 | 229 |
227 int ShaderDiskCacheEntry::IOComplete(int rv) { | 230 int ShaderDiskCacheEntry::IOComplete(int rv) { |
228 DCHECK(CalledOnValidThread()); | 231 DCHECK(CalledOnValidThread()); |
229 // Called through OnOpComplete, so we know |cache_| is valid. | 232 // Called through OnOpComplete, so we know |cache_| is valid. |
230 cache_->EntryComplete(this); | 233 cache_->EntryComplete(this); |
231 op_type_ = TERMINATE; | 234 op_type_ = TERMINATE; |
232 return rv; | 235 return rv; |
233 } | 236 } |
234 | 237 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 if (rv == net::ERR_FAILED) { | 300 if (rv == net::ERR_FAILED) { |
298 op_type_ = ITERATION_FINISHED; | 301 op_type_ = ITERATION_FINISHED; |
299 return net::OK; | 302 return net::OK; |
300 } | 303 } |
301 | 304 |
302 if (rv < 0) | 305 if (rv < 0) |
303 return rv; | 306 return rv; |
304 | 307 |
305 op_type_ = READ_COMPLETE; | 308 op_type_ = READ_COMPLETE; |
306 buf_ = new net::IOBufferWithSize(entry_->GetDataSize(1)); | 309 buf_ = new net::IOBufferWithSize(entry_->GetDataSize(1)); |
307 return entry_->ReadData(1, 0, buf_, buf_->size(), | 310 return entry_->ReadData( |
308 base::Bind(&ShaderDiskReadHelper::OnOpComplete, | 311 1, |
309 this)); | 312 0, |
| 313 buf_.get(), |
| 314 buf_->size(), |
| 315 base::Bind(&ShaderDiskReadHelper::OnOpComplete, this)); |
310 } | 316 } |
311 | 317 |
312 int ShaderDiskReadHelper::ReadComplete(int rv) { | 318 int ShaderDiskReadHelper::ReadComplete(int rv) { |
313 DCHECK(CalledOnValidThread()); | 319 DCHECK(CalledOnValidThread()); |
314 // Called through OnOpComplete, so we know |cache_| is valid. | 320 // Called through OnOpComplete, so we know |cache_| is valid. |
315 if (rv && rv == buf_->size()) { | 321 if (rv && rv == buf_->size()) { |
316 GpuProcessHost* host = GpuProcessHost::FromID(host_id_); | 322 GpuProcessHost* host = GpuProcessHost::FromID(host_id_); |
317 if (host) | 323 if (host) |
318 host->LoadedShader(entry_->GetKey(), std::string(buf_->data(), | 324 host->LoadedShader(entry_->GetKey(), std::string(buf_->data(), |
319 buf_->size())); | 325 buf_->size())); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 const net::CompletionCallback& callback) { | 609 const net::CompletionCallback& callback) { |
604 if (entry_map_.empty()) { | 610 if (entry_map_.empty()) { |
605 return net::OK; | 611 return net::OK; |
606 } | 612 } |
607 cache_complete_callback_ = callback; | 613 cache_complete_callback_ = callback; |
608 return net::ERR_IO_PENDING; | 614 return net::ERR_IO_PENDING; |
609 } | 615 } |
610 | 616 |
611 } // namespace content | 617 } // namespace content |
612 | 618 |
OLD | NEW |