Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_DOOMED_RESOURCE_HANDLER_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_DOOMED_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 while activated for a URLRequest. This is used for requests that | |
|
darin (slow to review)
2012/01/12 06:22:52
this second sentence is particular to the way you
battre
2012/01/13 15:52:22
Done.
| |
| 14 // are paused to be transferred to a new renderer. | |
| 15 class DoomedResourceHandler : public ResourceHandler { | |
| 16 public: | |
| 17 // As the DoomedResourceHandler is constructed and subsituted from code | |
|
darin (slow to review)
2012/01/12 06:22:52
nit: subsituted -> substituted
battre
2012/01/13 15:52:22
Done.
| |
| 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 | |
| 21 // destruction. | |
| 22 DoomedResourceHandler(ResourceHandler* old_handler); | |
|
darin (slow to review)
2012/01/12 06:22:52
nit: mark this "explicit"
battre
2012/01/13 15:52:22
Done.
| |
| 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 ~DoomedResourceHandler(); | |
| 52 | |
|
darin (slow to review)
2012/01/12 06:22:52
this comment is redundant. don't you say the same
battre
2012/01/13 15:52:22
Done.
| |
| 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_handler_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(DoomedResourceHandler); | |
| 60 }; | |
| 61 | |
| 62 #endif // CONTENT_BROWSER_RENDERER_HOST_DOOMED_RESOURCE_HANDLER_H_ | |
| OLD | NEW |