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 3 // found in the LICENSE file. 4 5 #include "content/browser/loader/layered_resource_handler.h" 6 7 #include "base/logging.h" 8 9 namespace content { 10 11 LayeredResourceHandler::LayeredResourceHandler( 12 net::URLRequest* request, 13 scoped_ptr<ResourceHandler> next_handler) 14 : ResourceHandler(request), 15 next_handler_(next_handler.Pass()) { 16 } 17 18 LayeredResourceHandler::~LayeredResourceHandler() { 19 } 20 21 void LayeredResourceHandler::SetController(ResourceController* controller) { 22 ResourceHandler::SetController(controller); 23 24 // Pass the controller down to the next handler. This method is intended to 25 // be overriden by subclasses of LayeredResourceHandler that need to insert a 26 // different ResourceController. 27 28 DCHECK(next_handler_.get()); 29 next_handler_->SetController(controller); 30 } 31 32 bool LayeredResourceHandler::OnUploadProgress(int request_id, uint64 position, 33 uint64 size) { 34 DCHECK(next_handler_.get()); 35 return next_handler_->OnUploadProgress(request_id, position, size); 36 } 37 38 bool LayeredResourceHandler::OnRequestRedirected(int request_id, 39 const GURL& url, 40 ResourceResponse* response, 41 bool* defer) { 42 DCHECK(next_handler_.get()); 43 return next_handler_->OnRequestRedirected(request_id, url, response, defer); 44 } 45 46 bool LayeredResourceHandler::OnResponseStarted(int request_id, 47 ResourceResponse* response, 48 bool* defer) { 49 DCHECK(next_handler_.get()); 50 return next_handler_->OnResponseStarted(request_id, response, defer); 51 } 52 53 bool LayeredResourceHandler::OnWillStart(int request_id, const GURL& url, 54 bool* defer) { 55 DCHECK(next_handler_.get()); 56 return next_handler_->OnWillStart(request_id, url, defer); 57 } 58 59 bool LayeredResourceHandler::OnWillRead(int request_id, 60 scoped_refptr<net::IOBuffer>* buf, 61 int* buf_size, 62 int min_size) { 63 DCHECK(next_handler_.get()); 64 return next_handler_->OnWillRead(request_id, buf, buf_size, min_size); 65 } 66 67 bool LayeredResourceHandler::OnReadCompleted(int request_id, int bytes_read, 68 bool* defer) { 69 DCHECK(next_handler_.get()); 70 return next_handler_->OnReadCompleted(request_id, bytes_read, defer); 71 } 72 73 void LayeredResourceHandler::OnResponseCompleted( 74 int request_id, 75 const net::URLRequestStatus& status, 76 const std::string& security_info, 77 bool* defer) { 78 DCHECK(next_handler_.get()); 79 next_handler_->OnResponseCompleted(request_id, status, security_info, defer); 80 } 81 82 void LayeredResourceHandler::OnDataDownloaded(int request_id, 83 int bytes_downloaded) { 84 DCHECK(next_handler_.get()); 85 next_handler_->OnDataDownloaded(request_id, bytes_downloaded); 86 } 87 88 } // namespace content 89