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

Side by Side Diff: content/browser/loader/cross_site_resource_handler.h

Issue 1384113002: CrossSiteResourceHandler: cancel request if the RFH is gone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_isolate_apps
Patch Set: Add EXPECT_TRUE's Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_ 5 #ifndef CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "content/browser/loader/layered_resource_handler.h" 10 #include "content/browser/loader/layered_resource_handler.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "net/url_request/url_request_status.h" 12 #include "net/url_request/url_request_status.h"
13 13
14 namespace net { 14 namespace net {
15 class URLRequest; 15 class URLRequest;
16 } 16 }
17 17
18 namespace content { 18 namespace content {
19 19
20 struct TransitionLayerData; 20 struct TransitionLayerData;
21 21
22 // Ensures that responses are delayed for navigations that must be transferred 22 // Ensures that responses are delayed for navigations that must be transferred
23 // to a different process. This handler wraps an AsyncEventHandler, and it sits 23 // to a different process. This handler wraps an AsyncEventHandler, and it sits
24 // inside SafeBrowsing and Buffered event handlers. This is important, so that 24 // inside SafeBrowsing and Buffered event handlers. This is important, so that
25 // it can intercept OnResponseStarted after we determine that a response is safe 25 // it can intercept OnResponseStarted after we determine that a response is safe
26 // and not a download. 26 // and not a download.
27 class CrossSiteResourceHandler : public LayeredResourceHandler { 27 class CrossSiteResourceHandler : public LayeredResourceHandler {
28 public: 28 public:
29 enum class NavigationDecision {
30 TRANSFER_REQUIRED,
31 USE_EXISTING_RENDERER,
32 CANCEL_REQUEST
33 };
34
29 CrossSiteResourceHandler(scoped_ptr<ResourceHandler> next_handler, 35 CrossSiteResourceHandler(scoped_ptr<ResourceHandler> next_handler,
30 net::URLRequest* request); 36 net::URLRequest* request);
31 ~CrossSiteResourceHandler() override; 37 ~CrossSiteResourceHandler() override;
32 38
33 // ResourceHandler implementation: 39 // ResourceHandler implementation:
34 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, 40 bool OnRequestRedirected(const net::RedirectInfo& redirect_info,
35 ResourceResponse* response, 41 ResourceResponse* response,
36 bool* defer) override; 42 bool* defer) override;
37 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; 43 bool OnResponseStarted(ResourceResponse* response, bool* defer) override;
38 bool OnReadCompleted(int bytes_read, bool* defer) override; 44 bool OnReadCompleted(int bytes_read, bool* defer) override;
(...skipping 17 matching lines...) Expand all
56 62
57 // Defer the navigation to the UI thread to check whether transfer is required 63 // Defer the navigation to the UI thread to check whether transfer is required
58 // or not. Currently only used in --site-per-process. 64 // or not. Currently only used in --site-per-process.
59 bool DeferForNavigationPolicyCheck(ResourceRequestInfoImpl* info, 65 bool DeferForNavigationPolicyCheck(ResourceRequestInfoImpl* info,
60 ResourceResponse* response, 66 ResourceResponse* response,
61 bool* defer); 67 bool* defer);
62 68
63 bool OnNormalResponseStarted(ResourceResponse* response, 69 bool OnNormalResponseStarted(ResourceResponse* response,
64 bool* defer); 70 bool* defer);
65 71
66 void ResumeOrTransfer(bool is_transfer); 72 void ResumeOrTransfer(NavigationDecision decision);
67 void ResumeIfDeferred(); 73 void ResumeIfDeferred();
68 74
69 // Called when about to defer a request. Sets |did_defer_| and logs the 75 // Called when about to defer a request. Sets |did_defer_| and logs the
70 // defferral 76 // defferral
71 void OnDidDefer(); 77 void OnDidDefer();
72 78
73 bool has_started_response_; 79 bool has_started_response_;
74 bool in_cross_site_transition_; 80 bool in_cross_site_transition_;
75 bool completed_during_transition_; 81 bool completed_during_transition_;
76 bool did_defer_; 82 bool did_defer_;
77 net::URLRequestStatus completed_status_; 83 net::URLRequestStatus completed_status_;
78 std::string completed_security_info_; 84 std::string completed_security_info_;
79 scoped_refptr<ResourceResponse> response_; 85 scoped_refptr<ResourceResponse> response_;
80 86
81 // TODO(nasko): WeakPtr is needed in --site-per-process, since all navigations 87 // TODO(nasko): WeakPtr is needed in --site-per-process, since all navigations
82 // are deferred to the UI thread and come back to IO thread via 88 // are deferred to the UI thread and come back to IO thread via
83 // PostTaskAndReplyWithResult. If a transfer is needed, it goes back to the UI 89 // PostTaskAndReplyWithResult. If a transfer is needed, it goes back to the UI
84 // thread. This can be removed once the code is changed to only do one hop. 90 // thread. This can be removed once the code is changed to only do one hop.
85 base::WeakPtrFactory<CrossSiteResourceHandler> weak_ptr_factory_; 91 base::WeakPtrFactory<CrossSiteResourceHandler> weak_ptr_factory_;
86 92
87 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); 93 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler);
88 }; 94 };
89 95
90 } // namespace content 96 } // namespace content
91 97
92 #endif // CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_ 98 #endif // CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/cross_site_transfer_browsertest.cc ('k') | content/browser/loader/cross_site_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698