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 #ifndef CONTENT_BROWSER_LOADER_DOOMED_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_DOOMED_RESOURCE_HANDLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/loader/resource_handler.h"
13 // ResourceHandler that DCHECKs on all events but canceling and failing of
14 // requests while activated for a URLRequest.
15 class DoomedResourceHandler
: public ResourceHandler
{
17 // As the DoomedResourceHandler is constructed and substituted from code
18 // of another ResourceHandler, we need to make sure that this other handler
19 // does not lose its last reference and gets destroyed by being substituted.
20 // Therefore, we retain a reference to |old_handler| that prevents the
22 explicit DoomedResourceHandler(scoped_ptr
<ResourceHandler
> old_handler
);
23 virtual ~DoomedResourceHandler();
25 // ResourceHandler implementation:
26 virtual bool OnUploadProgress(int request_id
,
28 uint64 size
) OVERRIDE
;
29 virtual bool OnRequestRedirected(int request_id
,
31 ResourceResponse
* response
,
32 bool* defer
) OVERRIDE
;
33 virtual bool OnResponseStarted(int request_id
,
34 ResourceResponse
* response
,
35 bool* defer
) OVERRIDE
;
36 virtual bool OnWillStart(int request_id
,
38 bool* defer
) OVERRIDE
;
39 virtual bool OnWillRead(int request_id
,
42 int min_size
) OVERRIDE
;
43 virtual bool OnReadCompleted(int request_id
,
45 bool* defer
) OVERRIDE
;
46 virtual bool OnResponseCompleted(int request_id
,
47 const net::URLRequestStatus
& status
,
48 const std::string
& security_info
) OVERRIDE
;
49 virtual void OnDataDownloaded(int request_id
,
50 int bytes_downloaded
) OVERRIDE
;
53 scoped_ptr
<ResourceHandler
> old_handler_
;
55 DISALLOW_COPY_AND_ASSIGN(DoomedResourceHandler
);
58 } // namespace content
60 #endif // CONTENT_BROWSER_LOADER_DOOMED_RESOURCE_HANDLER_H_