Commit 72b1eacd authored by tiago.vignatti's avatar tiago.vignatti Committed by Commit bot

Simplify FakeGpuProcess* video accelerator tests

Make DispatchToGpuPlatformSupportTask and DispatchToGpuPlatformSupportHostTask
statics, removing the weak ptrs (and failing DCHECKS in that code) altogether.

BUG=447798

Review URL: https://codereview.chromium.org/1017673003

Cr-Commit-Position: refs/heads/master@{#321212}
parent e13a9d57
...@@ -21,11 +21,18 @@ const int kGpuProcessHostId = 1; ...@@ -21,11 +21,18 @@ const int kGpuProcessHostId = 1;
} // namespace } // namespace
static void DispatchToGpuPlatformSupportHostTask(IPC::Message* msg) {
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
->OnMessageReceived(*msg);
delete msg;
}
class FakeGpuProcess : public IPC::Sender { class FakeGpuProcess : public IPC::Sender {
public: public:
FakeGpuProcess( FakeGpuProcess(
const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner)
: ui_task_runner_(ui_task_runner), weak_factory_(this) {} : ui_task_runner_(ui_task_runner) {}
~FakeGpuProcess() override {} ~FakeGpuProcess() override {}
void Init() { void Init() {
...@@ -43,35 +50,30 @@ class FakeGpuProcess : public IPC::Sender { ...@@ -43,35 +50,30 @@ class FakeGpuProcess : public IPC::Sender {
bool Send(IPC::Message* msg) override { bool Send(IPC::Message* msg) override {
ui_task_runner_->PostTask( ui_task_runner_->PostTask(
FROM_HERE, FROM_HERE, base::Bind(&DispatchToGpuPlatformSupportHostTask, msg));
base::Bind(&FakeGpuProcess::DispatchToGpuPlatformSupportHostTask,
weak_factory_.GetWeakPtr(), msg));
return true; return true;
} }
private: private:
void DispatchToGpuPlatformSupportHostTask(IPC::Message* msg) {
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
->OnMessageReceived(*msg);
delete msg;
}
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
base::WeakPtrFactory<FakeGpuProcess> weak_factory_;
}; };
static void DispatchToGpuPlatformSupportTask(IPC::Message* msg) {
ui::OzonePlatform::GetInstance()->GetGpuPlatformSupport()->OnMessageReceived(
*msg);
delete msg;
}
class FakeGpuProcessHost { class FakeGpuProcessHost {
public: public:
FakeGpuProcessHost( FakeGpuProcessHost(
const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner)
: gpu_task_runner_(gpu_task_runner), weak_factory_(this) {} : gpu_task_runner_(gpu_task_runner) {}
~FakeGpuProcessHost() {} ~FakeGpuProcessHost() {}
void Init() { void Init() {
base::Callback<void(IPC::Message*)> sender = base::Callback<void(IPC::Message*)> sender =
base::Bind(&FakeGpuProcessHost::DispatchToGpuPlatformSupportTask, base::Bind(&DispatchToGpuPlatformSupportTask);
weak_factory_.GetWeakPtr());
ui::OzonePlatform::GetInstance() ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost() ->GetGpuPlatformSupportHost()
...@@ -79,15 +81,7 @@ class FakeGpuProcessHost { ...@@ -79,15 +81,7 @@ class FakeGpuProcessHost {
} }
private: private:
void DispatchToGpuPlatformSupportTask(IPC::Message* msg) {
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupport()
->OnMessageReceived(*msg);
delete msg;
}
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_;
base::WeakPtrFactory<FakeGpuProcessHost> weak_factory_;
}; };
OzoneGpuTestHelper::OzoneGpuTestHelper() { OzoneGpuTestHelper::OzoneGpuTestHelper() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment