Index: ui/ozone/public/ui_thread_gpu.cc |
diff --git a/ui/ozone/public/ui_thread_gpu.cc b/ui/ozone/public/ui_thread_gpu.cc |
index aeb08b137e037d417dde5a6a7159b0717048fdb3..207f4f5adc3d7c0db130d78fee1175b897633eac 100644 |
--- a/ui/ozone/public/ui_thread_gpu.cc |
+++ b/ui/ozone/public/ui_thread_gpu.cc |
@@ -23,12 +23,12 @@ const int kGpuProcessHostId = 1; |
class FakeGpuProcess : public IPC::Sender { |
public: |
- FakeGpuProcess() : weak_factory_(this) {} |
+ FakeGpuProcess( |
+ const scoped_refptr<base::SingleThreadTaskRunner>& browser_task_runner) |
+ : browser_task_runner_(browser_task_runner), weak_factory_(this) {} |
~FakeGpuProcess() override {} |
void Init() { |
- task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
- |
ui::OzonePlatform::GetInstance() |
->GetGpuPlatformSupport() |
->OnChannelEstablished(this); |
@@ -42,8 +42,7 @@ class FakeGpuProcess : public IPC::Sender { |
} |
bool Send(IPC::Message* msg) override { |
- DCHECK(task_runner_->BelongsToCurrentThread()); |
- base::MessageLoop::current()->PostTask( |
+ browser_task_runner_->PostTask( |
spang
2015/02/19 01:55:09
s/browser_/ui_/
Browser is a process, not a threa
dnicoara
2015/02/19 06:04:33
Done.
|
FROM_HERE, |
base::Bind(&FakeGpuProcess::DispatchToGpuPlatformSupportHostTask, |
weak_factory_.GetWeakPtr(), msg)); |
@@ -58,37 +57,36 @@ class FakeGpuProcess : public IPC::Sender { |
delete msg; |
} |
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ scoped_refptr<base::SingleThreadTaskRunner> browser_task_runner_; |
base::WeakPtrFactory<FakeGpuProcess> weak_factory_; |
}; |
class FakeGpuProcessHost { |
public: |
- FakeGpuProcessHost() : weak_factory_(this) {} |
+ FakeGpuProcessHost( |
+ const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) |
+ : gpu_task_runner_(gpu_task_runner), weak_factory_(this) {} |
~FakeGpuProcessHost() {} |
void Init() { |
- task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
- |
base::Callback<void(IPC::Message*)> sender = |
base::Bind(&FakeGpuProcessHost::DispatchToGpuPlatformSupportTask, |
weak_factory_.GetWeakPtr()); |
ui::OzonePlatform::GetInstance() |
->GetGpuPlatformSupportHost() |
- ->OnChannelEstablished(kGpuProcessHostId, task_runner_, sender); |
+ ->OnChannelEstablished(kGpuProcessHostId, gpu_task_runner_, sender); |
} |
private: |
void DispatchToGpuPlatformSupportTask(IPC::Message* msg) { |
- DCHECK(task_runner_->BelongsToCurrentThread()); |
ui::OzonePlatform::GetInstance() |
->GetGpuPlatformSupport() |
->OnMessageReceived(*msg); |
delete msg; |
} |
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
+ scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_; |
base::WeakPtrFactory<FakeGpuProcessHost> weak_factory_; |
}; |
@@ -98,19 +96,21 @@ UiThreadGpu::UiThreadGpu() { |
UiThreadGpu::~UiThreadGpu() { |
} |
-bool UiThreadGpu::Initialize() { |
+bool UiThreadGpu::Initialize( |
+ const scoped_refptr<base::SingleThreadTaskRunner>& browser_task_runner, |
+ const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) { |
io_helper_thread_.reset(new base::Thread("IOHelperThread")); |
if (!io_helper_thread_->StartWithOptions( |
base::Thread::Options(base::MessageLoop::TYPE_IO, 0))) |
return false; |
- fake_gpu_process_.reset(new FakeGpuProcess); |
+ fake_gpu_process_.reset(new FakeGpuProcess(browser_task_runner)); |
io_helper_thread_->task_runner()->PostTask( |
FROM_HERE, base::Bind(&FakeGpuProcess::InitOnIO, |
base::Unretained(fake_gpu_process_.get()))); |
fake_gpu_process_->Init(); |
- fake_gpu_process_host_.reset(new FakeGpuProcessHost); |
+ fake_gpu_process_host_.reset(new FakeGpuProcessHost(gpu_task_runner)); |
fake_gpu_process_host_->Init(); |
return true; |