OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/gpu_process_host_ui_shim.h" |
| 6 |
| 7 #include "chrome/browser/chrome_thread.h" |
| 8 #include "chrome/browser/gpu_process_host.h" |
| 9 #include "chrome/common/gpu_messages.h" |
| 10 |
| 11 // Tasks used by this file |
| 12 namespace { |
| 13 |
| 14 class SendOnIOThreadTask : public Task { |
| 15 public: |
| 16 explicit SendOnIOThreadTask(IPC::Message* msg) : msg_(msg) { |
| 17 } |
| 18 |
| 19 private: |
| 20 void Run() { |
| 21 GpuProcessHost::Get()->Send(msg_); |
| 22 } |
| 23 IPC::Message* msg_; |
| 24 }; |
| 25 |
| 26 } // namespace |
| 27 |
| 28 GpuProcessHostUIShim::GpuProcessHostUIShim() : last_routing_id_(1) { |
| 29 } |
| 30 |
| 31 GpuProcessHostUIShim::~GpuProcessHostUIShim() { |
| 32 } |
| 33 |
| 34 // static |
| 35 GpuProcessHostUIShim* GpuProcessHostUIShim::Get() { |
| 36 return Singleton<GpuProcessHostUIShim>::get(); |
| 37 } |
| 38 |
| 39 int32 GpuProcessHostUIShim::NewRenderWidgetHostView( |
| 40 GpuNativeWindowHandle parent) { |
| 41 int32 routing_id = GetNextRoutingId(); |
| 42 Send(new GpuMsg_NewRenderWidgetHostView(parent, routing_id)); |
| 43 return routing_id; |
| 44 } |
| 45 |
| 46 bool GpuProcessHostUIShim::Send(IPC::Message* msg) { |
| 47 ChromeThread::PostTask(ChromeThread::IO, |
| 48 FROM_HERE, |
| 49 new SendOnIOThreadTask(msg)); |
| 50 return true; |
| 51 } |
| 52 |
| 53 int32 GpuProcessHostUIShim::GetNextRoutingId() { |
| 54 return ++last_routing_id_; |
| 55 } |
| 56 |
| 57 void GpuProcessHostUIShim::AddRoute(int32 routing_id, |
| 58 IPC::Channel::Listener* listener) { |
| 59 router_.AddRoute(routing_id, listener); |
| 60 } |
| 61 |
| 62 void GpuProcessHostUIShim::RemoveRoute(int32 routing_id) { |
| 63 router_.RemoveRoute(routing_id); |
| 64 } |
| 65 |
| 66 void GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) { |
| 67 router_.RouteMessage(message); |
| 68 } |
| 69 |
OLD | NEW |