Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Unified Diff: services/ui/ws/gpu_host.h

Issue 2741343003: Update liftetime management of GpuClient (Closed)
Patch Set: missing deps: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/ui/ws/gpu_host.h
diff --git a/services/ui/ws/gpu_host.h b/services/ui/ws/gpu_host.h
index b937266a5cc7136b079d451ae36d421b6797c376..5c59aeacd2d6358a291428c4591b1c7c8ecdea0b 100644
--- a/services/ui/ws/gpu_host.h
+++ b/services/ui/ws/gpu_host.h
@@ -5,6 +5,7 @@
#ifndef SERVICES_UI_WS_GPU_HOST_H_
#define SERVICES_UI_WS_GPU_HOST_H_
+#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
@@ -12,6 +13,7 @@
#include "gpu/ipc/client/gpu_channel_host.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_binding_set.h"
#include "services/ui/gpu/gpu_main.h"
#include "services/ui/gpu/interfaces/gpu_host.mojom.h"
#include "services/ui/gpu/interfaces/gpu_service.mojom.h"
@@ -23,6 +25,10 @@ class ServerGpuMemoryBufferManager;
namespace ws {
+namespace test {
+class GpuHostTest;
+} // namespace test
+
class GpuHostDelegate;
// Sets up connection from clients to the real service implementation in the GPU
@@ -42,6 +48,45 @@ class GpuHost : public mojom::GpuHost {
cc::mojom::DisplayCompositorClientPtr client);
private:
+ friend class test::GpuHostTest;
+
+ // The implementation that relays requests from clients to the real
+ // service implementation in the GPU process over mojom.GpuService.
+ class GpuClient : public base::SupportsWeakPtr<GpuClient>, public mojom::Gpu {
sadrul 2017/03/22 16:41:13 Use a WeakPtrFactory<> instead
jonross 2017/03/23 00:38:29 Done.
+ public:
+ GpuClient(int client_id,
+ gpu::GPUInfo* gpu_info,
+ ServerGpuMemoryBufferManager* gpu_memory_buffer_manager,
+ mojom::GpuService* gpu_service);
+ ~GpuClient() override;
+
+ private:
+ friend class test::GpuHostTest;
+ void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback,
+ mojo::ScopedMessagePipeHandle channel_handle);
+ // mojom::Gpu overrides:
+ void EstablishGpuChannel(
+ const EstablishGpuChannelCallback& callback) override;
+ void CreateGpuMemoryBuffer(
+ gfx::GpuMemoryBufferId id,
+ const gfx::Size& size,
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage,
+ const mojom::Gpu::CreateGpuMemoryBufferCallback& callback) override;
+ void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
+ const gpu::SyncToken& sync_token) override;
+
+ const int client_id_;
+
+ // The objects these pointers refer to are owned by the GpuHost object.
+ const gpu::GPUInfo* gpu_info_;
+ ServerGpuMemoryBufferManager* gpu_memory_buffer_manager_;
+ mojom::GpuService* gpu_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuClient);
sadrul 2017/03/22 16:41:13 Move this into a separate file.
jonross 2017/03/23 00:38:29 Done.
+ };
+
+ mojom::Gpu* AddInternal(mojom::GpuRequest request);
void OnBadMessageFromGpu();
// mojom::GpuHost:
@@ -72,6 +117,8 @@ class GpuHost : public mojom::GpuHost {
// because that will live in another process soon.
std::unique_ptr<GpuMain> gpu_main_impl_;
+ mojo::StrongBindingSet<mojom::Gpu> gpu_bindings_;
+
DISALLOW_COPY_AND_ASSIGN(GpuHost);
};
« no previous file with comments | « services/ui/ws/DEPS ('k') | services/ui/ws/gpu_host.cc » ('j') | services/ui/ws/gpu_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698