| Index: chrome/browser/automation/testing_automation_provider.cc
|
| diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
|
| index cdca45a98a7533f929433fa5525f2fbd791fe435..d7535dbd040f4297ec6188eff5e79d29d345a627 100644
|
| --- a/chrome/browser/automation/testing_automation_provider.cc
|
| +++ b/chrome/browser/automation/testing_automation_provider.cc
|
| @@ -135,6 +135,8 @@
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/render_messages.h"
|
| #include "chrome/common/url_constants.h"
|
| +#include "content/browser/gpu/gpu_process_host.h"
|
| +#include "content/common/gpu/gpu_messages.h"
|
| #include "content/public/browser/browser_child_process_host_iterator.h"
|
| #include "content/public/browser/child_process_data.h"
|
| #include "content/public/browser/favicon_status.h"
|
| @@ -2022,6 +2024,8 @@ void TestingAutomationProvider::BuildJSONHandlerMaps() {
|
| &TestingAutomationProvider::GetV8HeapStats;
|
| browser_handler_map_["GetFPS"] =
|
| &TestingAutomationProvider::GetFPS;
|
| + browser_handler_map_["GetGpuMemStats"] =
|
| + &TestingAutomationProvider::GetGpuMemStats;
|
|
|
| browser_handler_map_["IsFullscreenForBrowser"] =
|
| &TestingAutomationProvider::IsFullscreenForBrowser;
|
| @@ -5878,6 +5882,68 @@ void TestingAutomationProvider::GetFPS(
|
| render_view->Send(new ChromeViewMsg_GetFPS(routing_id));
|
| }
|
|
|
| +// Class to use for the callback from GpuProcessHost when memory
|
| +// stats are received
|
| +class GpuProcessHostOnMemStatsCallback {
|
| + public:
|
| + GpuProcessHostOnMemStatsCallback(
|
| + TestingAutomationProvider* provider,
|
| + IPC::Message* reply_message) :
|
| + provider_(provider),
|
| + reply_message_(reply_message) {
|
| + }
|
| + ~GpuProcessHostOnMemStatsCallback() {
|
| + }
|
| + void OnMemStatsCallback(const content::GpuMemStats& mem_stats) {
|
| + DictionaryValue dict;
|
| + dict.SetBoolean("gpu_active", true);
|
| + dict.SetInteger("gpu_memory_bytes_total", mem_stats.total_bytes);
|
| + dict.SetInteger("gpu_memory_bytes_used",
|
| + mem_stats.currently_allocated_bytes);
|
| + AutomationJSONReply(provider_, reply_message_).SendSuccess(&dict);
|
| + delete this;
|
| + }
|
| +
|
| + private:
|
| + TestingAutomationProvider* provider_;
|
| + IPC::Message* reply_message_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(GpuProcessHostOnMemStatsCallback);
|
| +};
|
| +
|
| +void TestingAutomationProvider::GetGpuMemStats(
|
| + Browser* browser,
|
| + DictionaryValue* args,
|
| + IPC::Message* reply_message) {
|
| + // Execute on the IO thread, since this needs to talk to the GPU process
|
| + if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&TestingAutomationProvider::GetGpuMemStats, this, browser,
|
| + args, reply_message));
|
| + return;
|
| + }
|
| +
|
| + GpuProcessHost* host = GpuProcessHost::Get(
|
| + GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
|
| + content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH);
|
| + if (host) {
|
| + // This object will delete itself upon receiving the OnMemStats callback
|
| + // from the GpuProcessHost
|
| + GpuProcessHostOnMemStatsCallback* callback =
|
| + new GpuProcessHostOnMemStatsCallback(this, reply_message);
|
| + host->SetOnMemStatsCallback(
|
| + base::Bind(&GpuProcessHostOnMemStatsCallback::OnMemStatsCallback,
|
| + base::Unretained(callback)));
|
| + host->Send(new GpuMsg_GetMemStats());
|
| + } else {
|
| + DictionaryValue dict;
|
| + dict.SetBoolean("gpu_active", false);
|
| + AutomationJSONReply(this, reply_message).SendSuccess(&dict);
|
| + }
|
| +}
|
| +
|
| void TestingAutomationProvider::IsFullscreenForBrowser(Browser* browser,
|
| base::DictionaryValue* args,
|
| IPC::Message* reply_message) {
|
|
|