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 #include "chrome/browser/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 #include "chrome/common/prerender_types.h" | 51 #include "chrome/common/prerender_types.h" |
52 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
53 #include "content/public/browser/devtools_agent_host.h" | 53 #include "content/public/browser/devtools_agent_host.h" |
54 #include "content/public/browser/navigation_controller.h" | 54 #include "content/public/browser/navigation_controller.h" |
55 #include "content/public/browser/notification_service.h" | 55 #include "content/public/browser/notification_service.h" |
56 #include "content/public/browser/notification_source.h" | 56 #include "content/public/browser/notification_source.h" |
57 #include "content/public/browser/render_frame_host.h" | 57 #include "content/public/browser/render_frame_host.h" |
58 #include "content/public/browser/render_process_host.h" | 58 #include "content/public/browser/render_process_host.h" |
59 #include "content/public/browser/render_view_host.h" | 59 #include "content/public/browser/render_view_host.h" |
60 #include "content/public/browser/session_storage_namespace.h" | 60 #include "content/public/browser/session_storage_namespace.h" |
61 #include "content/public/browser/site_instance.h" | |
61 #include "content/public/browser/web_contents.h" | 62 #include "content/public/browser/web_contents.h" |
62 #include "content/public/browser/web_contents_delegate.h" | 63 #include "content/public/browser/web_contents_delegate.h" |
63 #include "content/public/browser/web_contents_view.h" | 64 #include "content/public/browser/web_contents_view.h" |
64 #include "content/public/common/url_constants.h" | 65 #include "content/public/common/url_constants.h" |
65 #include "extensions/common/constants.h" | 66 #include "extensions/common/constants.h" |
66 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 67 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
67 #include "net/url_request/url_request_context.h" | 68 #include "net/url_request/url_request_context.h" |
68 #include "net/url_request/url_request_context_getter.h" | 69 #include "net/url_request/url_request_context_getter.h" |
69 | 70 |
70 using content::BrowserThread; | 71 using content::BrowserThread; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 final_status != FINAL_STATUS_TIMED_OUT && | 122 final_status != FINAL_STATUS_TIMED_OUT && |
122 final_status != FINAL_STATUS_MANAGER_SHUTDOWN && | 123 final_status != FINAL_STATUS_MANAGER_SHUTDOWN && |
123 final_status != FINAL_STATUS_PROFILE_DESTROYED && | 124 final_status != FINAL_STATUS_PROFILE_DESTROYED && |
124 final_status != FINAL_STATUS_APP_TERMINATING && | 125 final_status != FINAL_STATUS_APP_TERMINATING && |
125 final_status != FINAL_STATUS_WINDOW_OPENER && | 126 final_status != FINAL_STATUS_WINDOW_OPENER && |
126 final_status != FINAL_STATUS_CACHE_OR_HISTORY_CLEARED && | 127 final_status != FINAL_STATUS_CACHE_OR_HISTORY_CLEARED && |
127 final_status != FINAL_STATUS_CANCELLED && | 128 final_status != FINAL_STATUS_CANCELLED && |
128 final_status != FINAL_STATUS_DEVTOOLS_ATTACHED && | 129 final_status != FINAL_STATUS_DEVTOOLS_ATTACHED && |
129 final_status != FINAL_STATUS_CROSS_SITE_NAVIGATION_PENDING && | 130 final_status != FINAL_STATUS_CROSS_SITE_NAVIGATION_PENDING && |
130 final_status != FINAL_STATUS_PAGE_BEING_CAPTURED && | 131 final_status != FINAL_STATUS_PAGE_BEING_CAPTURED && |
131 final_status != FINAL_STATUS_NAVIGATION_UNCOMMITTED; | 132 final_status != FINAL_STATUS_NAVIGATION_UNCOMMITTED && |
133 final_status != FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE; | |
132 } | 134 } |
133 | 135 |
134 void CheckIfCookiesExistForDomainResultOnUIThread( | 136 void CheckIfCookiesExistForDomainResultOnUIThread( |
135 const net::CookieMonster::HasCookiesForETLDP1Callback& callback, | 137 const net::CookieMonster::HasCookiesForETLDP1Callback& callback, |
136 bool cookies_exist) { | 138 bool cookies_exist) { |
137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
138 callback.Run(cookies_exist); | 140 callback.Run(cookies_exist); |
139 } | 141 } |
140 | 142 |
141 void CheckIfCookiesExistForDomainResultOnIOThread( | 143 void CheckIfCookiesExistForDomainResultOnIOThread( |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 // there is a pending entry, it may not commit. | 524 // there is a pending entry, it may not commit. |
523 // TODO(creis): If there is a pending navigation and no last committed | 525 // TODO(creis): If there is a pending navigation and no last committed |
524 // entry, we might be able to transfer the network request instead. | 526 // entry, we might be able to transfer the network request instead. |
525 if (!new_web_contents->GetController().CanPruneAllButLastCommitted()) { | 527 if (!new_web_contents->GetController().CanPruneAllButLastCommitted()) { |
526 // Abort this prerender so it is not used later. http://crbug.com/292121 | 528 // Abort this prerender so it is not used later. http://crbug.com/292121 |
527 prerender_data->contents()->Destroy(FINAL_STATUS_NAVIGATION_UNCOMMITTED); | 529 prerender_data->contents()->Destroy(FINAL_STATUS_NAVIGATION_UNCOMMITTED); |
528 return NULL; | 530 return NULL; |
529 } | 531 } |
530 } | 532 } |
531 | 533 |
534 // Do not swap if the target WebContents is not the only WebContents in its | |
535 // current BrowsingInstance. | |
536 if (web_contents->GetSiteInstance()->GetRelatedActiveContentsCount() != 1u) { | |
davidben
2014/04/28 18:34:39
Would we ever have a WebContents where a frame is
Charlie Reis
2014/04/29 00:48:06
Let me chat with Nasko about this. I'd like to sa
davidben
2014/04/29 17:01:25
Well, if this does end up happening, probably this
Charlie Reis
2014/04/29 17:31:08
Let's assume that it won't happen, apart from <web
| |
537 DCHECK_GT( | |
538 web_contents->GetSiteInstance()->GetRelatedActiveContentsCount(), 1u); | |
539 prerender_data->contents()->Destroy( | |
540 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE); | |
541 return NULL; | |
542 } | |
543 | |
532 // Do not use the prerendered version if there is an opener object. | 544 // Do not use the prerendered version if there is an opener object. |
533 if (web_contents->HasOpener()) { | 545 if (web_contents->HasOpener()) { |
534 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER); | 546 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER); |
535 return NULL; | 547 return NULL; |
536 } | 548 } |
537 | 549 |
538 // Do not swap in the prerender if the current WebContents is being captured. | 550 // Do not swap in the prerender if the current WebContents is being captured. |
539 if (web_contents->GetCapturerCount() > 0) { | 551 if (web_contents->GetCapturerCount() > 0) { |
540 prerender_data->contents()->Destroy(FINAL_STATUS_PAGE_BEING_CAPTURED); | 552 prerender_data->contents()->Destroy(FINAL_STATUS_PAGE_BEING_CAPTURED); |
541 return NULL; | 553 return NULL; |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1822 histograms_->RecordNetworkBytes(used, prerender_bytes, recent_profile_bytes); | 1834 histograms_->RecordNetworkBytes(used, prerender_bytes, recent_profile_bytes); |
1823 } | 1835 } |
1824 | 1836 |
1825 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64 bytes) { | 1837 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64 bytes) { |
1826 DCHECK_GE(bytes, 0); | 1838 DCHECK_GE(bytes, 0); |
1827 if (IsEnabled() && ActuallyPrerendering()) | 1839 if (IsEnabled() && ActuallyPrerendering()) |
1828 profile_network_bytes_ += bytes; | 1840 profile_network_bytes_ += bytes; |
1829 } | 1841 } |
1830 | 1842 |
1831 } // namespace prerender | 1843 } // namespace prerender |
OLD | NEW |