OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 // We can now send the response to the new renderer, which will cause | 43 // We can now send the response to the new renderer, which will cause |
44 // WebContentsImpl to swap in the new renderer and destroy the old one. | 44 // WebContentsImpl to swap in the new renderer and destroy the old one. |
45 void ResumeResponse(); | 45 void ResumeResponse(); |
46 | 46 |
47 // When set to true, requests are leaked when they can't be passed to a | 47 // When set to true, requests are leaked when they can't be passed to a |
48 // RenderViewHost, for unit tests. | 48 // RenderViewHost, for unit tests. |
49 CONTENT_EXPORT static void SetLeakRequestsForTesting( | 49 CONTENT_EXPORT static void SetLeakRequestsForTesting( |
50 bool leak_requests_for_testing); | 50 bool leak_requests_for_testing); |
51 | 51 |
| 52 // Navigations are deferred at OnResponseStarted to parse out any navigation |
| 53 // transition link headers, and give the navigation transition (if it exists) |
| 54 // a chance to run. |
| 55 void ResumeResponseDeferredAtStart(int request_id); |
| 56 |
| 57 // Returns whether the handler is deferred. |
| 58 bool did_defer_for_testing() const { return did_defer_; } |
| 59 |
52 private: | 60 private: |
53 // Prepare to render the cross-site response in a new RenderViewHost, by | 61 // Prepare to render the cross-site response in a new RenderViewHost, by |
54 // telling the old RenderViewHost to run its onunload handler. | 62 // telling the old RenderViewHost to run its onunload handler. |
55 void StartCrossSiteTransition(ResourceResponse* response, | 63 void StartCrossSiteTransition(ResourceResponse* response, |
56 bool should_transfer); | 64 bool should_transfer); |
57 | 65 |
58 // Defer the navigation to the UI thread to check whether transfer is required | 66 // Defer the navigation to the UI thread to check whether transfer is required |
59 // or not. Currently only used in --site-per-process. | 67 // or not. Currently only used in --site-per-process. |
60 bool DeferForNavigationPolicyCheck(ResourceRequestInfoImpl* info, | 68 bool DeferForNavigationPolicyCheck(ResourceRequestInfoImpl* info, |
61 ResourceResponse* response, | 69 ResourceResponse* response, |
62 bool* defer); | 70 bool* defer); |
63 | 71 |
| 72 bool OnNavigationTransitionResponseStarted(ResourceResponse* response, |
| 73 bool* defer); |
| 74 |
| 75 bool OnNormalResponseStarted(ResourceResponse* response, |
| 76 bool* defer); |
| 77 |
64 void ResumeOrTransfer(bool is_transfer); | 78 void ResumeOrTransfer(bool is_transfer); |
65 void ResumeIfDeferred(); | 79 void ResumeIfDeferred(); |
66 | 80 |
67 // Called when about to defer a request. Sets |did_defer_| and logs the | 81 // Called when about to defer a request. Sets |did_defer_| and logs the |
68 // defferral | 82 // defferral |
69 void OnDidDefer(); | 83 void OnDidDefer(); |
70 | 84 |
71 bool has_started_response_; | 85 bool has_started_response_; |
72 bool in_cross_site_transition_; | 86 bool in_cross_site_transition_; |
73 bool completed_during_transition_; | 87 bool completed_during_transition_; |
74 bool did_defer_; | 88 bool did_defer_; |
75 net::URLRequestStatus completed_status_; | 89 net::URLRequestStatus completed_status_; |
76 std::string completed_security_info_; | 90 std::string completed_security_info_; |
77 scoped_refptr<ResourceResponse> response_; | 91 scoped_refptr<ResourceResponse> response_; |
78 | 92 |
79 // TODO(nasko): WeakPtr is needed in --site-per-process, since all navigations | 93 // TODO(nasko): WeakPtr is needed in --site-per-process, since all navigations |
80 // are deferred to the UI thread and come back to IO thread via | 94 // are deferred to the UI thread and come back to IO thread via |
81 // PostTaskAndReplyWithResult. If a transfer is needed, it goes back to the UI | 95 // PostTaskAndReplyWithResult. If a transfer is needed, it goes back to the UI |
82 // thread. This can be removed once the code is changed to only do one hop. | 96 // thread. This can be removed once the code is changed to only do one hop. |
83 base::WeakPtrFactory<CrossSiteResourceHandler> weak_ptr_factory_; | 97 base::WeakPtrFactory<CrossSiteResourceHandler> weak_ptr_factory_; |
84 | 98 |
85 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); | 99 DISALLOW_COPY_AND_ASSIGN(CrossSiteResourceHandler); |
86 }; | 100 }; |
87 | 101 |
88 } // namespace content | 102 } // namespace content |
89 | 103 |
90 #endif // CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_ | 104 #endif // CONTENT_BROWSER_LOADER_CROSS_SITE_RESOURCE_HANDLER_H_ |
OLD | NEW |