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

Side by Side Diff: webkit/appcache/appcache_service.cc

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/appcache/appcache_service.h" 5 #include "webkit/appcache/appcache_service.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 delete this; 367 delete this;
368 return; 368 return;
369 } 369 }
370 370
371 // Verify that we can read the response info and data. 371 // Verify that we can read the response info and data.
372 expected_total_size_ = entry->response_size(); 372 expected_total_size_ = entry->response_size();
373 response_reader_.reset(service_->storage()->CreateResponseReader( 373 response_reader_.reset(service_->storage()->CreateResponseReader(
374 manifest_url_, group->group_id(), response_id_)); 374 manifest_url_, group->group_id(), response_id_));
375 info_buffer_ = new HttpResponseInfoIOBuffer(); 375 info_buffer_ = new HttpResponseInfoIOBuffer();
376 response_reader_->ReadInfo( 376 response_reader_->ReadInfo(
377 info_buffer_, base::Bind(&CheckResponseHelper::OnReadInfoComplete, 377 info_buffer_.get(),
378 base::Unretained(this))); 378 base::Bind(&CheckResponseHelper::OnReadInfoComplete,
379 base::Unretained(this)));
379 } 380 }
380 381
381 void AppCacheService::CheckResponseHelper::OnReadInfoComplete(int result) { 382 void AppCacheService::CheckResponseHelper::OnReadInfoComplete(int result) {
382 if (result < 0) { 383 if (result < 0) {
383 AppCacheHistograms::CountCheckResponseResult( 384 AppCacheHistograms::CountCheckResponseResult(
384 AppCacheHistograms::READ_HEADERS_ERROR); 385 AppCacheHistograms::READ_HEADERS_ERROR);
385 service_->DeleteAppCacheGroup(manifest_url_, net::CompletionCallback()); 386 service_->DeleteAppCacheGroup(manifest_url_, net::CompletionCallback());
386 delete this; 387 delete this;
387 return; 388 return;
388 } 389 }
389 amount_headers_read_ = result; 390 amount_headers_read_ = result;
390 391
391 // Start reading the data. 392 // Start reading the data.
392 data_buffer_ = new net::IOBuffer(kIOBufferSize); 393 data_buffer_ = new net::IOBuffer(kIOBufferSize);
393 response_reader_->ReadData( 394 response_reader_->ReadData(
394 data_buffer_, kIOBufferSize, 395 data_buffer_.get(),
396 kIOBufferSize,
395 base::Bind(&CheckResponseHelper::OnReadDataComplete, 397 base::Bind(&CheckResponseHelper::OnReadDataComplete,
396 base::Unretained(this))); 398 base::Unretained(this)));
397 } 399 }
398 400
399 void AppCacheService::CheckResponseHelper::OnReadDataComplete(int result) { 401 void AppCacheService::CheckResponseHelper::OnReadDataComplete(int result) {
400 if (result > 0) { 402 if (result > 0) {
401 // Keep reading until we've read thru everything or failed to read. 403 // Keep reading until we've read thru everything or failed to read.
402 amount_data_read_ += result; 404 amount_data_read_ += result;
403 response_reader_->ReadData( 405 response_reader_->ReadData(
404 data_buffer_, kIOBufferSize, 406 data_buffer_.get(),
407 kIOBufferSize,
405 base::Bind(&CheckResponseHelper::OnReadDataComplete, 408 base::Bind(&CheckResponseHelper::OnReadDataComplete,
406 base::Unretained(this))); 409 base::Unretained(this)));
407 return; 410 return;
408 } 411 }
409 412
410 AppCacheHistograms::CheckResponseResultType check_result; 413 AppCacheHistograms::CheckResponseResultType check_result;
411 if (result < 0) 414 if (result < 0)
412 check_result = AppCacheHistograms::READ_DATA_ERROR; 415 check_result = AppCacheHistograms::READ_DATA_ERROR;
413 else if (info_buffer_->response_data_size != amount_data_read_ || 416 else if (info_buffer_->response_data_size != amount_data_read_ ||
414 expected_total_size_ != amount_data_read_ + amount_headers_read_) 417 expected_total_size_ != amount_data_read_ + amount_headers_read_)
415 check_result = AppCacheHistograms::UNEXPECTED_DATA_SIZE; 418 check_result = AppCacheHistograms::UNEXPECTED_DATA_SIZE;
416 else 419 else
417 check_result = AppCacheHistograms::RESPONSE_OK; 420 check_result = AppCacheHistograms::RESPONSE_OK;
418 AppCacheHistograms::CountCheckResponseResult(check_result); 421 AppCacheHistograms::CountCheckResponseResult(check_result);
419 422
420 if (check_result != AppCacheHistograms::RESPONSE_OK) 423 if (check_result != AppCacheHistograms::RESPONSE_OK)
421 service_->DeleteAppCacheGroup(manifest_url_, net::CompletionCallback()); 424 service_->DeleteAppCacheGroup(manifest_url_, net::CompletionCallback());
422 delete this; 425 delete this;
423 } 426 }
424 427
425 428
426 // AppCacheService ------- 429 // AppCacheService -------
427 430
428 AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy) 431 AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy)
429 : appcache_policy_(NULL), quota_client_(NULL), 432 : appcache_policy_(NULL), quota_client_(NULL),
430 quota_manager_proxy_(quota_manager_proxy), 433 quota_manager_proxy_(quota_manager_proxy),
431 request_context_(NULL), 434 request_context_(NULL),
432 force_keep_session_state_(false) { 435 force_keep_session_state_(false) {
433 if (quota_manager_proxy_) { 436 if (quota_manager_proxy_.get()) {
434 quota_client_ = new AppCacheQuotaClient(this); 437 quota_client_ = new AppCacheQuotaClient(this);
435 quota_manager_proxy_->RegisterClient(quota_client_); 438 quota_manager_proxy_->RegisterClient(quota_client_);
436 } 439 }
437 } 440 }
438 441
439 AppCacheService::~AppCacheService() { 442 AppCacheService::~AppCacheService() {
440 DCHECK(backends_.empty()); 443 DCHECK(backends_.empty());
441 std::for_each(pending_helpers_.begin(), 444 std::for_each(pending_helpers_.begin(),
442 pending_helpers_.end(), 445 pending_helpers_.end(),
443 std::mem_fun(&AsyncHelper::Cancel)); 446 std::mem_fun(&AsyncHelper::Cancel));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 backends_.insert( 511 backends_.insert(
509 BackendMap::value_type(backend_impl->process_id(), backend_impl)); 512 BackendMap::value_type(backend_impl->process_id(), backend_impl));
510 } 513 }
511 514
512 void AppCacheService::UnregisterBackend( 515 void AppCacheService::UnregisterBackend(
513 AppCacheBackendImpl* backend_impl) { 516 AppCacheBackendImpl* backend_impl) {
514 backends_.erase(backend_impl->process_id()); 517 backends_.erase(backend_impl->process_id());
515 } 518 }
516 519
517 } // namespace appcache 520 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_response_unittest.cc ('k') | webkit/appcache/appcache_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698