| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ | 5 #ifndef CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ |
| 6 #define CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ | 6 #define CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // This class lives on the UI thread and supports classes like the | 9 // This class lives on the UI thread and supports classes like the |
| 10 // BackingStoreProxy, which must live on the UI thread. The IO thread | 10 // BackingStoreProxy, which must live on the UI thread. The IO thread |
| 11 // portion of this class, the GpuProcessHost, is responsible for | 11 // portion of this class, the GpuProcessHost, is responsible for |
| 12 // shuttling messages between the browser and GPU processes. | 12 // shuttling messages between the browser and GPU processes. |
| 13 | 13 |
| 14 #include "base/callback.h" |
| 14 #include "base/non_thread_safe.h" | 15 #include "base/non_thread_safe.h" |
| 16 #include "base/scoped_ptr.h" |
| 15 #include "base/singleton.h" | 17 #include "base/singleton.h" |
| 16 #include "chrome/common/gpu_info.h" | 18 #include "chrome/common/gpu_info.h" |
| 17 #include "chrome/common/message_router.h" | 19 #include "chrome/common/message_router.h" |
| 18 #include "ipc/ipc_channel.h" | 20 #include "ipc/ipc_channel.h" |
| 19 #include "gfx/native_widget_types.h" | 21 #include "gfx/native_widget_types.h" |
| 20 | 22 |
| 21 class GpuProcessHostUIShim : public IPC::Channel::Sender, | 23 class GpuProcessHostUIShim : public IPC::Channel::Sender, |
| 22 public IPC::Channel::Listener, | 24 public IPC::Channel::Listener, |
| 23 public NonThreadSafe { | 25 public NonThreadSafe { |
| 24 public: | 26 public: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 47 // Tells the GPU process to crash. Useful for testing. | 49 // Tells the GPU process to crash. Useful for testing. |
| 48 void SendAboutGpuCrash(); | 50 void SendAboutGpuCrash(); |
| 49 | 51 |
| 50 // Tells the GPU process to let its main thread enter an infinite loop. | 52 // Tells the GPU process to let its main thread enter an infinite loop. |
| 51 // Useful for testing. | 53 // Useful for testing. |
| 52 void SendAboutGpuHang(); | 54 void SendAboutGpuHang(); |
| 53 | 55 |
| 54 // Return all known information about the GPU. | 56 // Return all known information about the GPU. |
| 55 const GPUInfo& gpu_info() const; | 57 const GPUInfo& gpu_info() const; |
| 56 | 58 |
| 59 // Used only in testing. Sets a callback to invoke when GPU info is collected, |
| 60 // regardless of whether it has been collected already or if it is partial |
| 61 // or complete info. Set to NULL when the callback should no longer be called. |
| 62 void set_gpu_info_collected_callback(Callback0::Type* callback) { |
| 63 gpu_info_collected_callback_.reset(callback); |
| 64 } |
| 65 |
| 57 private: | 66 private: |
| 58 friend struct DefaultSingletonTraits<GpuProcessHostUIShim>; | 67 friend struct DefaultSingletonTraits<GpuProcessHostUIShim>; |
| 59 | 68 |
| 60 GpuProcessHostUIShim(); | 69 GpuProcessHostUIShim(); |
| 61 virtual ~GpuProcessHostUIShim(); | 70 virtual ~GpuProcessHostUIShim(); |
| 62 | 71 |
| 63 // Message handlers. | 72 // Message handlers. |
| 64 void OnGraphicsInfoCollected(const GPUInfo& gpu_info); | 73 void OnGraphicsInfoCollected(const GPUInfo& gpu_info); |
| 65 void OnScheduleComposite(int32 renderer_id, int32 render_view_id); | 74 void OnScheduleComposite(int32 renderer_id, int32 render_view_id); |
| 66 void OnControlMessageReceived(const IPC::Message& message); | 75 void OnControlMessageReceived(const IPC::Message& message); |
| 67 | 76 |
| 68 int last_routing_id_; | 77 int last_routing_id_; |
| 69 | 78 |
| 70 GPUInfo gpu_info_; | 79 GPUInfo gpu_info_; |
| 71 | 80 |
| 72 MessageRouter router_; | 81 MessageRouter router_; |
| 82 |
| 83 // Used only in testing. If set, the callback is invoked when the GPU info |
| 84 // has been collected. |
| 85 scoped_ptr<Callback0::Type> gpu_info_collected_callback_; |
| 73 }; | 86 }; |
| 74 | 87 |
| 75 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ | 88 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_ |
| 76 | 89 |
| OLD | NEW |