| 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 "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "content/public/browser/gpu_data_manager.h" | 8 #include "content/public/browser/gpu_data_manager.h" |
| 9 #include "content/public/browser/gpu_data_manager_observer.h" | 9 #include "content/public/browser/gpu_data_manager_observer.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 url = gpu_test_dir_.AppendASCII("mem_webgl.html"); | 109 url = gpu_test_dir_.AppendASCII("mem_webgl.html"); |
| 110 break; | 110 break; |
| 111 } | 111 } |
| 112 | 112 |
| 113 NavigateToURL(tab_to_load, net::FilePathToFileURL(url)); | 113 NavigateToURL(tab_to_load, net::FilePathToFileURL(url)); |
| 114 std::ostringstream js_call; | 114 std::ostringstream js_call; |
| 115 js_call << "useGpuMemory("; | 115 js_call << "useGpuMemory("; |
| 116 js_call << mb_to_use; | 116 js_call << mb_to_use; |
| 117 js_call << ");"; | 117 js_call << ");"; |
| 118 std::string message; | 118 std::string message; |
| 119 ASSERT_TRUE( | 119 ASSERT_TRUE(ExecuteScriptInFrameAndExtractString( |
| 120 ExecuteScriptInFrameAndExtractString( | 120 tab_to_load->web_contents(), std::string(), js_call.str(), &message)); |
| 121 tab_to_load->web_contents(), | |
| 122 "", | |
| 123 js_call.str(), | |
| 124 &message)); | |
| 125 EXPECT_EQ("DONE_USE_GPU_MEMORY", message); | 121 EXPECT_EQ("DONE_USE_GPU_MEMORY", message); |
| 126 } | 122 } |
| 127 | 123 |
| 128 // Create a new tab. | 124 // Create a new tab. |
| 129 Shell* CreateNewTab() { | 125 Shell* CreateNewTab() { |
| 130 // The ContentBrowserTest will create one shell by default, use that one | 126 // The ContentBrowserTest will create one shell by default, use that one |
| 131 // first so that we don't confuse the memory manager into thinking there | 127 // first so that we don't confuse the memory manager into thinking there |
| 132 // are more windows than there are. | 128 // are more windows than there are. |
| 133 Shell* new_tab = has_used_first_shell_ ? CreateBrowser() : shell(); | 129 Shell* new_tab = has_used_first_shell_ ? CreateBrowser() : shell(); |
| 134 has_used_first_shell_ = true; | 130 has_used_first_shell_ = true; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // for stage 1 of the cycle. | 185 // for stage 1 of the cycle. |
| 190 for (std::set<Shell*>::iterator it = visible_tabs_.begin(); | 186 for (std::set<Shell*>::iterator it = visible_tabs_.begin(); |
| 191 it != visible_tabs_.end(); | 187 it != visible_tabs_.end(); |
| 192 ++it) { | 188 ++it) { |
| 193 std::string js_call( | 189 std::string js_call( |
| 194 "window.webkitRequestAnimationFrame(function() {" | 190 "window.webkitRequestAnimationFrame(function() {" |
| 195 " domAutomationController.setAutomationId(1);" | 191 " domAutomationController.setAutomationId(1);" |
| 196 " domAutomationController.send(\"DONE_RAF\");" | 192 " domAutomationController.send(\"DONE_RAF\");" |
| 197 "})"); | 193 "})"); |
| 198 std::string message; | 194 std::string message; |
| 199 ASSERT_TRUE( | 195 ASSERT_TRUE(ExecuteScriptInFrameAndExtractString( |
| 200 ExecuteScriptInFrameAndExtractString( | 196 (*it)->web_contents(), std::string(), js_call, &message)); |
| 201 (*it)->web_contents(), | |
| 202 "", | |
| 203 js_call, | |
| 204 &message)); | |
| 205 EXPECT_EQ("DONE_RAF", message); | 197 EXPECT_EQ("DONE_RAF", message); |
| 206 } | 198 } |
| 207 // TODO(ccameron): send an IPC from Browser -> Renderer (delay it until | 199 // TODO(ccameron): send an IPC from Browser -> Renderer (delay it until |
| 208 // painting finishes) -> GPU process (delay it until any pending manages | 200 // painting finishes) -> GPU process (delay it until any pending manages |
| 209 // happen) -> All Renderers -> Browser to flush parts 2, 3, and 4. | 201 // happen) -> All Renderers -> Browser to flush parts 2, 3, and 4. |
| 210 } | 202 } |
| 211 } | 203 } |
| 212 | 204 |
| 213 size_t GetMemoryUsageMbytes() { | 205 size_t GetMemoryUsageMbytes() { |
| 214 GpuMemoryBytesAllocatedObserver observer; | 206 GpuMemoryBytesAllocatedObserver observer; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 232 Shell* tab = CreateNewTab(); | 224 Shell* tab = CreateNewTab(); |
| 233 LoadPage(tab, PAGE_CSS3D, kMemoryLimitMB); | 225 LoadPage(tab, PAGE_CSS3D, kMemoryLimitMB); |
| 234 // Make sure that the CSS3D page maxes out a single tab's budget (otherwise | 226 // Make sure that the CSS3D page maxes out a single tab's budget (otherwise |
| 235 // the test doesn't test anything) but still stays under the limit. | 227 // the test doesn't test anything) but still stays under the limit. |
| 236 EXPECT_TRUE(MemoryUsageInRange( | 228 EXPECT_TRUE(MemoryUsageInRange( |
| 237 kSingleTabLimitMB - kWiggleRoomMB, | 229 kSingleTabLimitMB - kWiggleRoomMB, |
| 238 kMemoryLimitMB + kWiggleRoomMB)); | 230 kMemoryLimitMB + kWiggleRoomMB)); |
| 239 } | 231 } |
| 240 | 232 |
| 241 } // namespace content | 233 } // namespace content |
| OLD | NEW |