Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: content/browser/gpu/shader_disk_cache.cc

Issue 585833002: Revert of Remove void** from disk_cache interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698