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