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

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

Issue 297973002: Navigation transitions: Block first response until after transitions have run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 6 years, 6 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"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // We can now send the response to the new renderer, which will cause 47 // We can now send the response to the new renderer, which will cause
48 // WebContentsImpl to swap in the new renderer and destroy the old one. 48 // WebContentsImpl to swap in the new renderer and destroy the old one.
49 void ResumeResponse(); 49 void ResumeResponse();
50 50
51 // When set to true, requests are leaked when they can't be passed to a 51 // When set to true, requests are leaked when they can't be passed to a
52 // RenderViewHost, for unit tests. 52 // RenderViewHost, for unit tests.
53 CONTENT_EXPORT static void SetLeakRequestsForTesting( 53 CONTENT_EXPORT static void SetLeakRequestsForTesting(
54 bool leak_requests_for_testing); 54 bool leak_requests_for_testing);
55 55
56 // Navigations are deferred at OnResponseStarted to parse out any navigation
57 // transition link headers, and give the navigation transition (if it exists)
58 // a chance to run.
59 void ResumeResponseDeferredAtStart(int request_id);
60
61 // Returns whether the handler is deferred. This is designed for the
62 // browsertests.
63 bool is_deferred_for_testing() const { return did_defer_; }
jam 2014/06/11 02:00:21 nit: name should be did_defer_for_testing. also no
shatch 2014/06/14 00:41:37 That variable is used internally to check if the r
jam 2014/06/16 03:46:10 per http://google-styleguide.googlecode.com/svn/tr
shatch 2014/06/16 22:32:19 Done.
64
56 private: 65 private:
57 // Prepare to render the cross-site response in a new RenderViewHost, by 66 // Prepare to render the cross-site response in a new RenderViewHost, by
58 // telling the old RenderViewHost to run its onunload handler. 67 // telling the old RenderViewHost to run its onunload handler.
59 void StartCrossSiteTransition(int request_id, 68 void StartCrossSiteTransition(int request_id,
60 ResourceResponse* response, 69 ResourceResponse* response,
61 bool should_transfer); 70 bool should_transfer);
62 71
63 // Defer the navigation to the UI thread to check whether transfer is required 72 // Defer the navigation to the UI thread to check whether transfer is required
64 // or not. Currently only used in --site-per-process. 73 // or not. Currently only used in --site-per-process.
65 bool DeferForNavigationPolicyCheck(ResourceRequestInfoImpl* info, 74 bool DeferForNavigationPolicyCheck(ResourceRequestInfoImpl* info,
66 ResourceResponse* response, 75 ResourceResponse* response,
67 bool* defer); 76 bool* defer);
68 77
78 bool OnNavigationTransitionResponseStarted(int request_id,
79 ResourceResponse* response,
80 bool* defer);
81
82 bool OnNormalResponseStarted(int request_id,
83 ResourceResponse* response,
84 bool* defer);
85
69 void ResumeOrTransfer(bool is_transfer); 86 void ResumeOrTransfer(bool is_transfer);
70 void ResumeIfDeferred(); 87 void ResumeIfDeferred();
71 88
72 // Called when about to defer a request. Sets |did_defer_| and logs the 89 // Called when about to defer a request. Sets |did_defer_| and logs the
73 // defferral 90 // defferral
74 void OnDidDefer(); 91 void OnDidDefer();
75 92
76 bool has_started_response_; 93 bool has_started_response_;
77 bool in_cross_site_transition_; 94 bool in_cross_site_transition_;
78 bool completed_during_transition_; 95 bool completed_during_transition_;
79 bool did_defer_; 96 bool did_defer_;
80 net::URLRequestStatus completed_status_; 97 net::URLRequestStatus completed_status_;
81 std::string completed_security_info_; 98 std::string completed_security_info_;
82 scoped_refptr<ResourceResponse> response_; 99 scoped_refptr<ResourceResponse> response_;
83 100
84 // TODO(nasko): WeakPtr is needed in --site-per-process, since all navigations 101 // TODO(nasko): WeakPtr is needed in --site-per-process, since all navigations
85 // are deferred to the UI thread and come back to IO thread via 102 // are deferred to the UI thread and come back to IO thread via
86 // PostTaskAndReplyWithResult. If a transfer is needed, it goes back to the UI 103 // PostTaskAndReplyWithResult. If a transfer is needed, it goes back to the UI
87 // thread. This can be removed once the code is changed to only do one hop. 104 // thread. This can be removed once the code is changed to only do one hop.
88 base::WeakPtrFactory<CrossSiteResourceHandler> weak_ptr_factory_; 105 base::WeakPtrFactory<CrossSiteResourceHandler> weak_ptr_factory_;
89 106
90 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); 107 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler);
91 }; 108 };
92 109
93 } // namespace content 110 } // namespace content
94 111
95 #endif // CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_ 112 #endif // CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698