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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10702200: PyAuto test for GPU memory consumption (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated PyAuto test for GPU memory consumption. Created 8 years, 5 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 | Annotate | Revision Log
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 #include "chrome/browser/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 #include "chrome/common/chrome_notification_types.h" 128 #include "chrome/common/chrome_notification_types.h"
129 #include "chrome/common/chrome_paths.h" 129 #include "chrome/common/chrome_paths.h"
130 #include "chrome/common/chrome_switches.h" 130 #include "chrome/common/chrome_switches.h"
131 #include "chrome/common/extensions/extension.h" 131 #include "chrome/common/extensions/extension.h"
132 #include "chrome/common/extensions/extension_action.h" 132 #include "chrome/common/extensions/extension_action.h"
133 #include "chrome/common/extensions/url_pattern.h" 133 #include "chrome/common/extensions/url_pattern.h"
134 #include "chrome/common/extensions/url_pattern_set.h" 134 #include "chrome/common/extensions/url_pattern_set.h"
135 #include "chrome/common/pref_names.h" 135 #include "chrome/common/pref_names.h"
136 #include "chrome/common/render_messages.h" 136 #include "chrome/common/render_messages.h"
137 #include "chrome/common/url_constants.h" 137 #include "chrome/common/url_constants.h"
138 #include "content/browser/gpu/gpu_process_host.h"
139 #include "content/common/gpu/gpu_messages.h"
138 #include "content/public/browser/browser_child_process_host_iterator.h" 140 #include "content/public/browser/browser_child_process_host_iterator.h"
139 #include "content/public/browser/child_process_data.h" 141 #include "content/public/browser/child_process_data.h"
140 #include "content/public/browser/favicon_status.h" 142 #include "content/public/browser/favicon_status.h"
141 #include "content/public/browser/geolocation.h" 143 #include "content/public/browser/geolocation.h"
142 #include "content/public/browser/interstitial_page.h" 144 #include "content/public/browser/interstitial_page.h"
143 #include "content/public/browser/interstitial_page_delegate.h" 145 #include "content/public/browser/interstitial_page_delegate.h"
144 #include "content/public/browser/navigation_entry.h" 146 #include "content/public/browser/navigation_entry.h"
145 #include "content/public/browser/notification_service.h" 147 #include "content/public/browser/notification_service.h"
146 #include "content/public/browser/plugin_service.h" 148 #include "content/public/browser/plugin_service.h"
147 #include "content/public/browser/render_process_host.h" 149 #include "content/public/browser/render_process_host.h"
(...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 &TestingAutomationProvider::KillRendererProcess; 2017 &TestingAutomationProvider::KillRendererProcess;
2016 2018
2017 browser_handler_map_["LaunchApp"] = &TestingAutomationProvider::LaunchApp; 2019 browser_handler_map_["LaunchApp"] = &TestingAutomationProvider::LaunchApp;
2018 browser_handler_map_["SetAppLaunchType"] = 2020 browser_handler_map_["SetAppLaunchType"] =
2019 &TestingAutomationProvider::SetAppLaunchType; 2021 &TestingAutomationProvider::SetAppLaunchType;
2020 2022
2021 browser_handler_map_["GetV8HeapStats"] = 2023 browser_handler_map_["GetV8HeapStats"] =
2022 &TestingAutomationProvider::GetV8HeapStats; 2024 &TestingAutomationProvider::GetV8HeapStats;
2023 browser_handler_map_["GetFPS"] = 2025 browser_handler_map_["GetFPS"] =
2024 &TestingAutomationProvider::GetFPS; 2026 &TestingAutomationProvider::GetFPS;
2027 browser_handler_map_["GetGpuMemStats"] =
2028 &TestingAutomationProvider::GetGpuMemStats;
2025 2029
2026 browser_handler_map_["IsFullscreenForBrowser"] = 2030 browser_handler_map_["IsFullscreenForBrowser"] =
2027 &TestingAutomationProvider::IsFullscreenForBrowser; 2031 &TestingAutomationProvider::IsFullscreenForBrowser;
2028 browser_handler_map_["IsFullscreenForTab"] = 2032 browser_handler_map_["IsFullscreenForTab"] =
2029 &TestingAutomationProvider::IsFullscreenForTab; 2033 &TestingAutomationProvider::IsFullscreenForTab;
2030 browser_handler_map_["IsMouseLocked"] = 2034 browser_handler_map_["IsMouseLocked"] =
2031 &TestingAutomationProvider::IsMouseLocked; 2035 &TestingAutomationProvider::IsMouseLocked;
2032 browser_handler_map_["IsMouseLockPermissionRequested"] = 2036 browser_handler_map_["IsMouseLockPermissionRequested"] =
2033 &TestingAutomationProvider::IsMouseLockPermissionRequested; 2037 &TestingAutomationProvider::IsMouseLockPermissionRequested;
2034 browser_handler_map_["IsFullscreenPermissionRequested"] = 2038 browser_handler_map_["IsFullscreenPermissionRequested"] =
(...skipping 3836 matching lines...) Expand 10 before | Expand all | Expand 10 after
5871 int routing_id = render_view->GetRoutingID(); 5875 int routing_id = render_view->GetRoutingID();
5872 5876
5873 // This observer will delete itself. 5877 // This observer will delete itself.
5874 new FPSObserver( 5878 new FPSObserver(
5875 this, reply_message, 5879 this, reply_message,
5876 base::GetProcId(render_view->GetProcess()->GetHandle()), 5880 base::GetProcId(render_view->GetProcess()->GetHandle()),
5877 routing_id); 5881 routing_id);
5878 render_view->Send(new ChromeViewMsg_GetFPS(routing_id)); 5882 render_view->Send(new ChromeViewMsg_GetFPS(routing_id));
5879 } 5883 }
5880 5884
5885 // Class to use for the callback from GpuProcessHost when memory
5886 // stats are received
5887 class GpuProcessHostOnMemStatsCallback {
5888 public:
5889 GpuProcessHostOnMemStatsCallback(
5890 TestingAutomationProvider* provider,
5891 IPC::Message* reply_message) :
5892 provider_(provider),
5893 reply_message_(reply_message) {
5894 }
5895 ~GpuProcessHostOnMemStatsCallback() {
5896 }
5897 void OnMemStatsCallback(const content::GpuMemStats& mem_stats) {
5898 DictionaryValue dict;
5899 dict.SetBoolean("gpu_active", true);
5900 dict.SetInteger("gpu_memory_bytes_total", mem_stats.total_bytes);
5901 dict.SetInteger("gpu_memory_bytes_used",
5902 mem_stats.currently_allocated_bytes);
5903 AutomationJSONReply(provider_, reply_message_).SendSuccess(&dict);
5904 delete this;
5905 }
5906
5907 private:
5908 TestingAutomationProvider* provider_;
5909 IPC::Message* reply_message_;
5910
5911 DISALLOW_COPY_AND_ASSIGN(GpuProcessHostOnMemStatsCallback);
5912 };
5913
5914 void TestingAutomationProvider::GetGpuMemStats(
5915 Browser* browser,
5916 DictionaryValue* args,
5917 IPC::Message* reply_message) {
5918 // Execute on the IO thread, since this needs to talk to the GPU process
5919 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
5920 BrowserThread::PostTask(
5921 BrowserThread::IO,
5922 FROM_HERE,
5923 base::Bind(&TestingAutomationProvider::GetGpuMemStats, this, browser,
5924 args, reply_message));
5925 return;
5926 }
5927
5928 GpuProcessHost* host = GpuProcessHost::Get(
5929 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
5930 content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH);
5931 if (host) {
5932 // This object will delete itself upon receiving the OnMemStats callback
5933 // from the GpuProcessHost
5934 GpuProcessHostOnMemStatsCallback* callback =
5935 new GpuProcessHostOnMemStatsCallback(this, reply_message);
5936 host->SetOnMemStatsCallback(
5937 base::Bind(&GpuProcessHostOnMemStatsCallback::OnMemStatsCallback,
5938 base::Unretained(callback)));
5939 host->Send(new GpuMsg_GetMemStats());
5940 } else {
5941 DictionaryValue dict;
5942 dict.SetBoolean("gpu_active", false);
5943 AutomationJSONReply(this, reply_message).SendSuccess(&dict);
5944 }
5945 }
5946
5881 void TestingAutomationProvider::IsFullscreenForBrowser(Browser* browser, 5947 void TestingAutomationProvider::IsFullscreenForBrowser(Browser* browser,
5882 base::DictionaryValue* args, 5948 base::DictionaryValue* args,
5883 IPC::Message* reply_message) { 5949 IPC::Message* reply_message) {
5884 DictionaryValue dict; 5950 DictionaryValue dict;
5885 dict.SetBoolean("result", 5951 dict.SetBoolean("result",
5886 browser->fullscreen_controller()->IsFullscreenForBrowser()); 5952 browser->fullscreen_controller()->IsFullscreenForBrowser());
5887 AutomationJSONReply(this, reply_message).SendSuccess(&dict); 5953 AutomationJSONReply(this, reply_message).SendSuccess(&dict);
5888 } 5954 }
5889 5955
5890 void TestingAutomationProvider::IsFullscreenForTab(Browser* browser, 5956 void TestingAutomationProvider::IsFullscreenForTab(Browser* browser,
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
6770 void TestingAutomationProvider::OnRemoveProvider() { 6836 void TestingAutomationProvider::OnRemoveProvider() {
6771 if (g_browser_process) 6837 if (g_browser_process)
6772 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6838 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6773 } 6839 }
6774 6840
6775 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6841 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6776 WebContents* tab) { 6842 WebContents* tab) {
6777 if (chrome::GetActiveWebContents(browser) != tab) 6843 if (chrome::GetActiveWebContents(browser) != tab)
6778 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 6844 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
6779 } 6845 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698