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(int request_id
, uint64 position
,
34 DCHECK(next_handler_
.get());
35 return next_handler_
->OnUploadProgress(request_id
, position
, size
);
38 bool LayeredResourceHandler::OnRequestRedirected(int request_id
,
40 ResourceResponse
* response
,
42 DCHECK(next_handler_
.get());
43 return next_handler_
->OnRequestRedirected(request_id
, url
, response
, defer
);
46 bool LayeredResourceHandler::OnResponseStarted(int request_id
,
47 ResourceResponse
* response
,
49 DCHECK(next_handler_
.get());
50 return next_handler_
->OnResponseStarted(request_id
, response
, defer
);
53 bool LayeredResourceHandler::OnWillStart(int request_id
, const GURL
& url
,
55 DCHECK(next_handler_
.get());
56 return next_handler_
->OnWillStart(request_id
, url
, defer
);
59 bool LayeredResourceHandler::OnBeforeNetworkStart(int request_id
,
62 DCHECK(next_handler_
.get());
63 return next_handler_
->OnBeforeNetworkStart(request_id
, url
, defer
);
66 bool LayeredResourceHandler::OnWillRead(int request_id
,
67 scoped_refptr
<net::IOBuffer
>* buf
,
70 DCHECK(next_handler_
.get());
71 return next_handler_
->OnWillRead(request_id
, buf
, buf_size
, min_size
);
74 bool LayeredResourceHandler::OnReadCompleted(int request_id
, int bytes_read
,
76 DCHECK(next_handler_
.get());
77 return next_handler_
->OnReadCompleted(request_id
, bytes_read
, defer
);
80 void LayeredResourceHandler::OnResponseCompleted(
82 const net::URLRequestStatus
& status
,
83 const std::string
& security_info
,
85 DCHECK(next_handler_
.get());
86 next_handler_
->OnResponseCompleted(request_id
, status
, security_info
, defer
);
89 void LayeredResourceHandler::OnDataDownloaded(int request_id
,
90 int bytes_downloaded
) {
91 DCHECK(next_handler_
.get());
92 next_handler_
->OnDataDownloaded(request_id
, bytes_downloaded
);
95 } // namespace content