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

Side by Side Diff: chrome/browser/nacl_host/pnacl_translation_cache.cc

Issue 22608005: Add extra error logging to PnaclTranslationCache and PnaclHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/nacl_host/pnacl_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/nacl_host/pnacl_translation_cache.h" 5 #include "chrome/browser/nacl_host/pnacl_translation_cache.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 offset, 191 offset,
192 io_buf_.get(), 192 io_buf_.get(),
193 len, 193 len,
194 base::Bind(&PnaclTranslationCacheEntry::DispatchNext, this)); 194 base::Bind(&PnaclTranslationCacheEntry::DispatchNext, this));
195 if (rv != net::ERR_IO_PENDING) 195 if (rv != net::ERR_IO_PENDING)
196 DispatchNext(rv); 196 DispatchNext(rv);
197 } 197 }
198 198
199 void PnaclTranslationCacheEntry::CloseEntry(int rv) { 199 void PnaclTranslationCacheEntry::CloseEntry(int rv) {
200 DCHECK(entry_); 200 DCHECK(entry_);
201 if (rv < 0) 201 if (rv < 0) {
202 LOG(ERROR) << "PnaclTranslationCache: failed to close entry: "
203 << net::ErrorToString(rv);
202 entry_->Doom(); 204 entry_->Doom();
205 }
203 BrowserThread::PostTask( 206 BrowserThread::PostTask(
204 BrowserThread::IO, FROM_HERE, base::Bind(&CloseDiskCacheEntry, entry_)); 207 BrowserThread::IO, FROM_HERE, base::Bind(&CloseDiskCacheEntry, entry_));
205 Finish(rv); 208 Finish(rv);
206 } 209 }
207 210
208 void PnaclTranslationCacheEntry::Finish(int rv) { 211 void PnaclTranslationCacheEntry::Finish(int rv) {
209 if (is_read_) { 212 if (is_read_) {
210 if (!read_callback_.is_null()) { 213 if (!read_callback_.is_null()) {
211 read_callback_.Run(rv, io_buf_); 214 read_callback_.Run(rv, io_buf_);
212 read_callback_.Reset(); 215 read_callback_.Reset();
213 } 216 }
214 } else { 217 } else {
215 if (!write_callback_.is_null()) { 218 if (!write_callback_.is_null()) {
216 write_callback_.Run(rv); 219 write_callback_.Run(rv);
217 write_callback_.Reset(); 220 write_callback_.Reset();
218 } 221 }
219 } 222 }
220 cache_->OpComplete(this); 223 cache_->OpComplete(this);
221 } 224 }
222 225
223 void PnaclTranslationCacheEntry::DispatchNext(int rv) { 226 void PnaclTranslationCacheEntry::DispatchNext(int rv) {
224 DCHECK(thread_checker_.CalledOnValidThread()); 227 DCHECK(thread_checker_.CalledOnValidThread());
225 if (!cache_) 228 if (!cache_)
226 return; 229 return;
227 230
228 switch (step_) { 231 switch (step_) {
229 case UNINITIALIZED: 232 case UNINITIALIZED:
230 LOG(ERROR) << "Unexpected step in DispatchNext"; 233 LOG(ERROR) << "PnaclTranslationCache: DispatchNext called uninitialized";
231 break; 234 break;
232 235
233 case OPEN_ENTRY: 236 case OPEN_ENTRY:
234 if (rv == net::OK) { 237 if (rv == net::OK) {
235 step_ = TRANSFER_ENTRY; 238 step_ = TRANSFER_ENTRY;
236 if (is_read_) { 239 if (is_read_) {
237 int bytes_to_transfer = entry_->GetDataSize(1); 240 int bytes_to_transfer = entry_->GetDataSize(1);
238 io_buf_ = new net::DrainableIOBuffer( 241 io_buf_ = new net::DrainableIOBuffer(
239 new net::IOBuffer(bytes_to_transfer), bytes_to_transfer); 242 new net::IOBuffer(bytes_to_transfer), bytes_to_transfer);
240 ReadEntry(0, bytes_to_transfer); 243 ReadEntry(0, bytes_to_transfer);
241 } else { 244 } else {
242 WriteEntry(0, io_buf_->size()); 245 WriteEntry(0, io_buf_->size());
243 } 246 }
244 } else { 247 } else {
248 if (rv != net::ERR_FAILED) {
249 // ERROR_FAILED is what we expect if the entry doesn't exist.
250 LOG(ERROR) << "PnaclTranslationCache: OpenEntry failed: "
251 << net::ErrorToString(rv);
252 }
245 if (is_read_) { 253 if (is_read_) {
246 // Just a cache miss, not necessarily an error. 254 // Just a cache miss, not necessarily an error.
247 entry_ = NULL; 255 entry_ = NULL;
248 Finish(rv); 256 Finish(rv);
249 } else { 257 } else {
250 step_ = CREATE_ENTRY; 258 step_ = CREATE_ENTRY;
251 CreateEntry(); 259 CreateEntry();
252 } 260 }
253 } 261 }
254 break; 262 break;
255 263
256 case CREATE_ENTRY: 264 case CREATE_ENTRY:
257 if (rv == net::OK) { 265 if (rv == net::OK) {
258 step_ = TRANSFER_ENTRY; 266 step_ = TRANSFER_ENTRY;
259 WriteEntry(io_buf_->BytesConsumed(), io_buf_->BytesRemaining()); 267 WriteEntry(io_buf_->BytesConsumed(), io_buf_->BytesRemaining());
260 } else { 268 } else {
261 LOG(ERROR) << "Failed to Create a PNaCl Translation Cache Entry"; 269 LOG(ERROR) << "PnaclTranslationCache: Failed to Create Entry: "
270 << net::ErrorToString(rv);
262 Finish(rv); 271 Finish(rv);
263 } 272 }
264 break; 273 break;
265 274
266 case TRANSFER_ENTRY: 275 case TRANSFER_ENTRY:
267 if (rv < 0) { 276 if (rv < 0) {
268 // We do not call DispatchNext directly if WriteEntry/ReadEntry returns 277 // We do not call DispatchNext directly if WriteEntry/ReadEntry returns
269 // ERR_IO_PENDING, and the callback should not return that value either. 278 // ERR_IO_PENDING, and the callback should not return that value either.
270 LOG(ERROR) 279 LOG(ERROR)
271 << "Failed to complete write to PNaCl Translation Cache Entry: " 280 << "PnaclTranslationCache: Failed to complete write to entry: "
272 << rv; 281 << net::ErrorToString(rv);
273 step_ = CLOSE_ENTRY; 282 step_ = CLOSE_ENTRY;
274 CloseEntry(rv); 283 CloseEntry(rv);
275 break; 284 break;
276 } else if (rv > 0) { 285 } else if (rv > 0) {
277 io_buf_->DidConsume(rv); 286 io_buf_->DidConsume(rv);
278 if (io_buf_->BytesRemaining() > 0) { 287 if (io_buf_->BytesRemaining() > 0) {
279 is_read_ 288 is_read_
280 ? ReadEntry(io_buf_->BytesConsumed(), io_buf_->BytesRemaining()) 289 ? ReadEntry(io_buf_->BytesConsumed(), io_buf_->BytesRemaining())
281 : WriteEntry(io_buf_->BytesConsumed(), io_buf_->BytesRemaining()); 290 : WriteEntry(io_buf_->BytesConsumed(), io_buf_->BytesRemaining());
282 break; 291 break;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 &disk_cache_, 344 &disk_cache_,
336 base::Bind(&PnaclTranslationCache::OnCreateBackendComplete, AsWeakPtr())); 345 base::Bind(&PnaclTranslationCache::OnCreateBackendComplete, AsWeakPtr()));
337 init_callback_ = callback; 346 init_callback_ = callback;
338 if (rv != net::ERR_IO_PENDING) { 347 if (rv != net::ERR_IO_PENDING) {
339 OnCreateBackendComplete(rv); 348 OnCreateBackendComplete(rv);
340 } 349 }
341 return rv; 350 return rv;
342 } 351 }
343 352
344 void PnaclTranslationCache::OnCreateBackendComplete(int rv) { 353 void PnaclTranslationCache::OnCreateBackendComplete(int rv) {
354 if (rv < 0) {
355 LOG(ERROR) << "PnaclTranslationCache: backend init failed:"
356 << net::ErrorToString(rv);
357 }
345 // Invoke our client's callback function. 358 // Invoke our client's callback function.
346 if (!init_callback_.is_null()) { 359 if (!init_callback_.is_null()) {
347 init_callback_.Run(rv); 360 init_callback_.Run(rv);
348 init_callback_.Reset(); 361 init_callback_.Reset();
349 } 362 }
350 } 363 }
351 364
352 ////////////////////////////////////////////////////////////////////// 365 //////////////////////////////////////////////////////////////////////
353 // High-level API 366 // High-level API
354 367
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 440 }
428 441
429 int PnaclTranslationCache::DoomEntriesBetween( 442 int PnaclTranslationCache::DoomEntriesBetween(
430 base::Time initial, 443 base::Time initial,
431 base::Time end, 444 base::Time end,
432 const CompletionCallback& callback) { 445 const CompletionCallback& callback) {
433 return disk_cache_->DoomEntriesBetween(initial, end, callback); 446 return disk_cache_->DoomEntriesBetween(initial, end, callback);
434 } 447 }
435 448
436 } // namespace pnacl 449 } // namespace pnacl
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/pnacl_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698