Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(821)

Side by Side Diff: content/browser/renderer_host/transferred_resource_handler.h

Issue 9113028: Substitute ResourceHandlers with dummy ResourceHandler while request is transferred (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_TRANSFERRED_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_TRANSFERRED_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 TransferredResourceHandler : public ResourceHandler {
darin (slow to review) 2012/01/06 22:59:02 Perhaps it would be useful to factor out an Unreac
battre 2012/01/06 23:37:56 I think this is not very useful as we won't have a
16 public:
17 // As the TransferredResourceHandler 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 TransferredResourceHandler(ResourceHandler* old_handlers);
darin (slow to review) 2012/01/06 22:59:02 nit: why is this variable name pluralized? it is
battre 2012/01/06 23:37:56 It a linked chain of handlers. I don't mind using
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 ~TransferredResourceHandler();
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(TransferredResourceHandler);
60 };
61
62 #endif // CONTENT_BROWSER_RENDERER_HOST_TRANSFERRED_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698