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::OnRequestRedirected(
33 const net::RedirectInfo
& redirect_info
,
34 ResourceResponse
* response
,
36 DCHECK(next_handler_
.get());
37 return next_handler_
->OnRequestRedirected(redirect_info
, response
, defer
);
40 bool LayeredResourceHandler::OnResponseStarted(ResourceResponse
* response
,
42 DCHECK(next_handler_
.get());
43 return next_handler_
->OnResponseStarted(response
, defer
);
46 bool LayeredResourceHandler::OnWillStart(const GURL
& url
,
48 DCHECK(next_handler_
.get());
49 return next_handler_
->OnWillStart(url
, defer
);
52 bool LayeredResourceHandler::OnBeforeNetworkStart(const GURL
& url
,
54 DCHECK(next_handler_
.get());
55 return next_handler_
->OnBeforeNetworkStart(url
, defer
);
58 bool LayeredResourceHandler::OnWillRead(scoped_refptr
<net::IOBuffer
>* buf
,
61 DCHECK(next_handler_
.get());
62 return next_handler_
->OnWillRead(buf
, buf_size
, min_size
);
65 bool LayeredResourceHandler::OnReadCompleted(int bytes_read
, bool* defer
) {
66 DCHECK(next_handler_
.get());
67 return next_handler_
->OnReadCompleted(bytes_read
, defer
);
70 void LayeredResourceHandler::OnResponseCompleted(
71 const net::URLRequestStatus
& status
,
72 const std::string
& security_info
,
74 DCHECK(next_handler_
.get());
75 next_handler_
->OnResponseCompleted(status
, security_info
, defer
);
78 void LayeredResourceHandler::OnDataDownloaded(int bytes_downloaded
) {
79 DCHECK(next_handler_
.get());
80 next_handler_
->OnDataDownloaded(bytes_downloaded
);
83 } // namespace content