• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
LayeredResourceHandler(net::URLRequest * request,scoped_ptr<ResourceHandler> next_handler)11 LayeredResourceHandler::LayeredResourceHandler(
12     net::URLRequest* request,
13     scoped_ptr<ResourceHandler> next_handler)
14     : ResourceHandler(request),
15       next_handler_(next_handler.Pass()) {
16 }
17 
~LayeredResourceHandler()18 LayeredResourceHandler::~LayeredResourceHandler() {
19 }
20 
SetController(ResourceController * controller)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 
OnUploadProgress(uint64 position,uint64 size)32 bool LayeredResourceHandler::OnUploadProgress(uint64 position,
33                                               uint64 size) {
34   DCHECK(next_handler_.get());
35   return next_handler_->OnUploadProgress(position, size);
36 }
37 
OnRequestRedirected(const net::RedirectInfo & redirect_info,ResourceResponse * response,bool * defer)38 bool LayeredResourceHandler::OnRequestRedirected(
39     const net::RedirectInfo& redirect_info,
40     ResourceResponse* response,
41     bool* defer) {
42   DCHECK(next_handler_.get());
43   return next_handler_->OnRequestRedirected(redirect_info, response, defer);
44 }
45 
OnResponseStarted(ResourceResponse * response,bool * defer)46 bool LayeredResourceHandler::OnResponseStarted(ResourceResponse* response,
47                                                bool* defer) {
48   DCHECK(next_handler_.get());
49   return next_handler_->OnResponseStarted(response, defer);
50 }
51 
OnWillStart(const GURL & url,bool * defer)52 bool LayeredResourceHandler::OnWillStart(const GURL& url,
53                                          bool* defer) {
54   DCHECK(next_handler_.get());
55   return next_handler_->OnWillStart(url, defer);
56 }
57 
OnBeforeNetworkStart(const GURL & url,bool * defer)58 bool LayeredResourceHandler::OnBeforeNetworkStart(const GURL& url,
59                                                   bool* defer) {
60   DCHECK(next_handler_.get());
61   return next_handler_->OnBeforeNetworkStart(url, defer);
62 }
63 
OnWillRead(scoped_refptr<net::IOBuffer> * buf,int * buf_size,int min_size)64 bool LayeredResourceHandler::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
65                                         int* buf_size,
66                                         int min_size) {
67   DCHECK(next_handler_.get());
68   return next_handler_->OnWillRead(buf, buf_size, min_size);
69 }
70 
OnReadCompleted(int bytes_read,bool * defer)71 bool LayeredResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
72   DCHECK(next_handler_.get());
73   return next_handler_->OnReadCompleted(bytes_read, defer);
74 }
75 
OnResponseCompleted(const net::URLRequestStatus & status,const std::string & security_info,bool * defer)76 void LayeredResourceHandler::OnResponseCompleted(
77     const net::URLRequestStatus& status,
78     const std::string& security_info,
79     bool* defer) {
80   DCHECK(next_handler_.get());
81   next_handler_->OnResponseCompleted(status, security_info, defer);
82 }
83 
OnDataDownloaded(int bytes_downloaded)84 void LayeredResourceHandler::OnDataDownloaded(int bytes_downloaded) {
85   DCHECK(next_handler_.get());
86   next_handler_->OnDataDownloaded(bytes_downloaded);
87 }
88 
89 }  // namespace content
90