OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
Charlie Reis
2012/01/06 17:54:52
New files should use 2012, right?
battre
2012/01/06 18:39:04
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PAUSED_RESOURCE_HANDLER_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_PAUSED_RESOURCE_HANDLER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/memory/ref_counted.h" | |
10 #include "content/browser/renderer_host/resource_handler.h" | |
11 | |
12 // ResourceHandler that DCHECKs on all events but canceling and failing of | |
13 // requests. This is used for requests that are paused to be transferred to | |
14 // a new renderer. | |
15 class PausedResourceHandler : public ResourceHandler { | |
Charlie Reis
2012/01/06 17:54:52
Sorry, I'm not sure I agree on the name. There's
battre
2012/01/06 18:39:04
Lacking a better proposal I have renamed the class
| |
16 public: | |
17 // As the PausedResourceHandler is constructed and subsituted 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_handlers| that prevents the | |
21 // destruction. | |
22 PausedResourceHandler(ResourceHandler* old_handlers); | |
23 | |
24 // ResourceHandler implementation: | |
25 virtual bool OnUploadProgress(int request_id, | |
26 uint64 position, | |
27 uint64 size) OVERRIDE; | |
28 virtual bool OnRequestRedirected(int request_id, | |
29 const GURL& new_url, | |
30 content::ResourceResponse* response, | |
31 bool* defer) OVERRIDE; | |
32 virtual bool OnResponseStarted(int request_id, | |
33 content::ResourceResponse* response) OVERRIDE; | |
34 virtual bool OnWillStart(int request_id, | |
35 const GURL& url, | |
36 bool* defer) OVERRIDE; | |
37 virtual bool OnWillRead(int request_id, | |
38 net::IOBuffer** buf, | |
39 int* buf_size, | |
40 int min_size) OVERRIDE; | |
41 virtual bool OnReadCompleted(int request_id, | |
42 int* bytes_read) OVERRIDE; | |
43 virtual bool OnResponseCompleted(int request_id, | |
44 const net::URLRequestStatus& status, | |
45 const std::string& security_info) OVERRIDE; | |
46 virtual void OnRequestClosed() OVERRIDE; | |
47 virtual void OnDataDownloaded(int request_id, | |
48 int bytes_downloaded) OVERRIDE; | |
49 | |
50 private: | |
51 virtual ~PausedResourceHandler(); | |
52 | |
53 // Reference to the old ResourceHandlers that were active before this one | |
54 // replaced them. We need to retain a reference here because we replace | |
55 // the old handlers while they are being executed. Replacing them without | |
56 // retaining the reference might delete the last reference and destroy them. | |
57 scoped_refptr<ResourceHandler> old_handlers_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(PausedResourceHandler); | |
60 }; | |
61 | |
62 #endif // CONTENT_BROWSER_RENDERER_HOST_PAUSED_RESOURCE_HANDLER_H_ | |
OLD | NEW |