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

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

Issue 8991001: base::Bind: Convert most of webkit/appcache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix 2. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "webkit/appcache/view_appcache_internals_job.h" 8 #include "webkit/appcache/view_appcache_internals_job.h"
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // Job that shows the details of a particular cached resource. 498 // Job that shows the details of a particular cached resource.
499 class ViewEntryJob : public BaseInternalsJob, 499 class ViewEntryJob : public BaseInternalsJob,
500 public AppCacheStorage::Delegate { 500 public AppCacheStorage::Delegate {
501 public: 501 public:
502 ViewEntryJob( 502 ViewEntryJob(
503 net::URLRequest* request, AppCacheService* service, 503 net::URLRequest* request, AppCacheService* service,
504 const GURL& manifest_url, const GURL& entry_url, 504 const GURL& manifest_url, const GURL& entry_url,
505 int64 response_id, int64 group_id) 505 int64 response_id, int64 group_id)
506 : BaseInternalsJob(request, service), 506 : BaseInternalsJob(request, service),
507 manifest_url_(manifest_url), entry_url_(entry_url), 507 manifest_url_(manifest_url), entry_url_(entry_url),
508 response_id_(response_id), group_id_(group_id), amount_read_(0), 508 response_id_(response_id), group_id_(group_id), amount_read_(0) {
509 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( 509 }
510 this, &ViewEntryJob::OnReadComplete)) {}
511 510
512 virtual void Start() { 511 virtual void Start() {
513 DCHECK(request_); 512 DCHECK(request_);
514 appcache_service_->storage()->LoadResponseInfo( 513 appcache_service_->storage()->LoadResponseInfo(
515 manifest_url_, group_id_, response_id_, this); 514 manifest_url_, group_id_, response_id_, this);
516 } 515 }
517 516
518 // Produces a page containing the response headers and data. 517 // Produces a page containing the response headers and data.
519 virtual bool GetData(std::string* mime_type, 518 virtual bool GetData(std::string* mime_type,
520 std::string* charset, 519 std::string* charset,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 558
560 // Read the response data, truncating if its too large. 559 // Read the response data, truncating if its too large.
561 const int64 kLimit = 100 * 1000; 560 const int64 kLimit = 100 * 1000;
562 int64 amount_to_read = 561 int64 amount_to_read =
563 std::min(kLimit, response_info->response_data_size()); 562 std::min(kLimit, response_info->response_data_size());
564 response_data_ = new net::IOBuffer(amount_to_read); 563 response_data_ = new net::IOBuffer(amount_to_read);
565 564
566 reader_.reset(appcache_service_->storage()->CreateResponseReader( 565 reader_.reset(appcache_service_->storage()->CreateResponseReader(
567 manifest_url_, group_id_, response_id_)); 566 manifest_url_, group_id_, response_id_));
568 reader_->ReadData( 567 reader_->ReadData(
569 response_data_, amount_to_read, &read_callback_); 568 response_data_, amount_to_read,
569 base::Bind(&ViewEntryJob::OnReadComplete, base::Unretained(this)));
570 } 570 }
571 571
572 void OnReadComplete(int result) { 572 void OnReadComplete(int result) {
573 reader_.reset(); 573 reader_.reset();
574 amount_read_ = result; 574 amount_read_ = result;
575 if (result < 0) 575 if (result < 0)
576 response_data_ = NULL; 576 response_data_ = NULL;
577 StartAsync(); 577 StartAsync();
578 } 578 }
579 579
580 GURL manifest_url_; 580 GURL manifest_url_;
581 GURL entry_url_; 581 GURL entry_url_;
582 int64 response_id_; 582 int64 response_id_;
583 int64 group_id_; 583 int64 group_id_;
584 scoped_refptr<AppCacheResponseInfo> response_info_; 584 scoped_refptr<AppCacheResponseInfo> response_info_;
585 scoped_refptr<net::IOBuffer> response_data_; 585 scoped_refptr<net::IOBuffer> response_data_;
586 int amount_read_; 586 int amount_read_;
587 scoped_ptr<AppCacheResponseReader> reader_; 587 scoped_ptr<AppCacheResponseReader> reader_;
588 net::OldCompletionCallbackImpl<ViewEntryJob> read_callback_;
589 }; 588 };
590 589
591 } // namespace 590 } // namespace
592 591
593 net::URLRequestJob* ViewAppCacheInternalsJobFactory::CreateJobForRequest( 592 net::URLRequestJob* ViewAppCacheInternalsJobFactory::CreateJobForRequest(
594 net::URLRequest* request, AppCacheService* service) { 593 net::URLRequest* request, AppCacheService* service) {
595 if (!request->url().has_query()) 594 if (!request->url().has_query())
596 return new MainPageJob(request, service); 595 return new MainPageJob(request, service);
597 596
598 std::string command; 597 std::string command;
(...skipping 17 matching lines...) Expand all
616 return new ViewEntryJob(request, service, 615 return new ViewEntryJob(request, service,
617 DecodeBase64URL(tokens[0]), // manifest url 616 DecodeBase64URL(tokens[0]), // manifest url
618 DecodeBase64URL(tokens[1]), // entry url 617 DecodeBase64URL(tokens[1]), // entry url
619 response_id, group_id); 618 response_id, group_id);
620 } 619 }
621 620
622 return new RedirectToMainPageJob(request, service); 621 return new RedirectToMainPageJob(request, service);
623 } 622 }
624 623
625 } // namespace appcache 624 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/mock_appcache_storage.h ('k') | webkit/fileapi/file_system_dir_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698