OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """ | 5 """ |
6 Cache temperature specifies how the browser cache should be configured before | 6 Cache temperature specifies how the browser cache should be configured before |
7 the page run. | 7 the page run. |
8 | 8 |
9 See design doc for details: | 9 See design doc for details: |
10 https://docs.google.com/document/u/1/d/12D7tkhZi887g9d0U2askU9JypU_wYiEI7Lw0bfwx UgA | 10 https://docs.google.com/document/u/1/d/12D7tkhZi887g9d0U2askU9JypU_wYiEI7Lw0bfwx UgA |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 return True | 55 return True |
56 | 56 |
57 def EnsurePageCacheTemperature(page, browser, previous_page=None): | 57 def EnsurePageCacheTemperature(page, browser, previous_page=None): |
58 temperature = page.cache_temperature | 58 temperature = page.cache_temperature |
59 logging.info('PageCacheTemperature: %s', temperature) | 59 logging.info('PageCacheTemperature: %s', temperature) |
60 | 60 |
61 if temperature == ANY: | 61 if temperature == ANY: |
62 return | 62 return |
63 | 63 |
64 if temperature == COLD: | 64 if temperature == COLD: |
65 if previous_page is None: | 65 with MarkTelemetryInternal(browser, 'clear_cache'): |
66 with MarkTelemetryInternal(browser, 'ensure_diskcache'): | 66 any_tab = browser.tabs[0] |
67 tab = browser.tabs[0] | 67 any_tab.ClearCache(force=True) |
68 tab.Navigate("http://does.not.exist") | |
nednguyen
2017/09/19 09:40:27
Wait, where is this logic not needed any more?
yukiy
2017/09/19 10:08:20
This logic ensures that browser has any tab, but b
nednguyen
2017/09/19 10:25:00
I recall it does more than that. Otherwise we woul
yukiy
2017/09/21 07:20:16
Thanks ned, as you said this logic can't be remove
| |
69 tab.WaitForDocumentReadyStateToBeComplete() | |
70 | |
71 any_tab = browser.tabs[0] | |
72 any_tab.ClearCache(force=True) | |
73 elif temperature == WARM: | 68 elif temperature == WARM: |
74 if (previous_page is not None and | 69 if (previous_page is not None and |
75 previous_page.url == page.url and | 70 previous_page.url == page.url and |
76 (previous_page.cache_temperature == COLD or | 71 (previous_page.cache_temperature == COLD or |
77 previous_page.cache_temperature == WARM)): | 72 previous_page.cache_temperature == WARM)): |
78 if '#' in page.url: | 73 if '#' in page.url: |
79 # Navigate to inexistent URL to avoid in-page hash navigation. | 74 # Navigate to inexistent URL to avoid in-page hash navigation. |
80 # Note: Unlike PCv1, PCv2 iterates the same URL for different cache | 75 # Note: Unlike PCv1, PCv2 iterates the same URL for different cache |
81 # configurations. This may issue blink in-page hash navigations, | 76 # configurations. This may issue blink in-page hash navigations, |
82 # which isn't intended here. | 77 # which isn't intended here. |
83 with MarkTelemetryInternal(browser, 'avoid_double_hash_navigation'): | 78 with MarkTelemetryInternal(browser, 'avoid_double_hash_navigation'): |
84 tab = browser.tabs[0] | 79 tab = browser.tabs[0] |
85 tab.Navigate("http://does.not.exist") | 80 tab.Navigate("http://does.not.exist") |
86 tab.WaitForDocumentReadyStateToBeComplete() | 81 tab.WaitForDocumentReadyStateToBeComplete() |
87 return | 82 return |
88 | 83 |
89 with MarkTelemetryInternal(browser, 'warmCache'): | 84 with MarkTelemetryInternal(browser, 'warm_cache'): |
90 tab = browser.tabs[0] | 85 tab = browser.tabs[0] |
91 tab.Navigate(page.url) | 86 tab.Navigate(page.url) |
92 py_utils.WaitFor(tab.HasReachedQuiescence, 60) | 87 py_utils.WaitFor(tab.HasReachedQuiescence, 60) |
93 tab.WaitForDocumentReadyStateToBeComplete() | 88 tab.WaitForDocumentReadyStateToBeComplete() |
94 tab.Navigate("about:blank") | 89 tab.Navigate("about:blank") |
95 tab.WaitForDocumentReadyStateToBeComplete() | 90 tab.WaitForDocumentReadyStateToBeComplete() |
OLD | NEW |