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.
5 #include "content/browser/loader/layered_resource_handler.h"
7 #include "base/logging.h"
11 LayeredResourceHandler::LayeredResourceHandler(
12 net::URLRequest
* request
,
13 scoped_ptr
<ResourceHandler
> next_handler
)
14 : ResourceHandler(request
),
15 next_handler_(next_handler
.Pass()) {
18 LayeredResourceHandler::~LayeredResourceHandler() {
21 void LayeredResourceHandler::SetController(ResourceController
* controller
) {
22 ResourceHandler::SetController(controller
);
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.
28 DCHECK(next_handler_
.get());
29 next_handler_
->SetController(controller
);
32 bool LayeredResourceHandler::OnUploadProgress(uint64 position
,
34 DCHECK(next_handler_
.get());
35 return next_handler_
->OnUploadProgress(position
, size
);
38 bool LayeredResourceHandler::OnRequestRedirected(
39 const net::RedirectInfo
& redirect_info
,
40 ResourceResponse
* response
,
42 DCHECK(next_handler_
.get());
43 return next_handler_
->OnRequestRedirected(redirect_info
, response
, defer
);
46 bool LayeredResourceHandler::OnResponseStarted(ResourceResponse
* response
,
48 DCHECK(next_handler_
.get());
49 return next_handler_
->OnResponseStarted(response
, defer
);
52 bool LayeredResourceHandler::OnWillStart(const GURL
& url
,
54 DCHECK(next_handler_
.get());
55 return next_handler_
->OnWillStart(url
, defer
);
58 bool LayeredResourceHandler::OnBeforeNetworkStart(const GURL
& url
,
60 DCHECK(next_handler_
.get());
61 return next_handler_
->OnBeforeNetworkStart(url
, defer
);
64 bool LayeredResourceHandler::OnWillRead(scoped_refptr
<net::IOBuffer
>* buf
,
67 DCHECK(next_handler_
.get());
68 return next_handler_
->OnWillRead(buf
, buf_size
, min_size
);
71 bool LayeredResourceHandler::OnReadCompleted(int bytes_read
, bool* defer
) {
72 DCHECK(next_handler_
.get());
73 return next_handler_
->OnReadCompleted(bytes_read
, defer
);
76 void LayeredResourceHandler::OnResponseCompleted(
77 const net::URLRequestStatus
& status
,
78 const std::string
& security_info
,
80 DCHECK(next_handler_
.get());
81 next_handler_
->OnResponseCompleted(status
, security_info
, defer
);
84 void LayeredResourceHandler::OnDataDownloaded(int bytes_downloaded
) {
85 DCHECK(next_handler_
.get());
86 next_handler_
->OnDataDownloaded(bytes_downloaded
);
89 } // namespace content