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

Unified Diff: content/common/gpu/client/gpu_channel_host.h

Issue 1656433002: Sample code: IPC Transport object for GPU Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GpuMemoryBufferService + Transport object. TODO: Eliminate ChildThreadImpl dependency Created 4 years, 10 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: content/common/gpu/client/gpu_channel_host.h
diff --git a/content/common/gpu/client/gpu_channel_host.h b/content/common/gpu/client/gpu_channel_host.h
index bf7b3894c210f0133a7f579d509aef2e99043002..13b3611f57a981c4c80e2d2bdeb68edd2838017d 100644
--- a/content/common/gpu/client/gpu_channel_host.h
+++ b/content/common/gpu/client/gpu_channel_host.h
@@ -20,14 +20,11 @@
#include "base/process/process.h"
#include "base/synchronization/lock.h"
#include "content/common/content_export.h"
+#include "content/common/gpu/client/ipc/gpu_channel_host_ipc_transport.h"
#include "content/common/gpu/gpu_process_launch_causes.h"
#include "content/common/gpu/gpu_result_codes.h"
#include "content/common/gpu/gpu_stream_priority.h"
-#include "content/common/message_router.h"
#include "gpu/config/gpu_info.h"
-#include "ipc/ipc_channel_handle.h"
-#include "ipc/ipc_sync_channel.h"
-#include "ipc/message_filter.h"
#include "media/video/jpeg_decode_accelerator.h"
#include "ui/events/latency_info.h"
#include "ui/gfx/geometry/size.h"
@@ -37,7 +34,6 @@
class GURL;
class TransportTextureService;
-struct GPUCreateCommandBufferConfig;
namespace base {
class MessageLoop;
@@ -61,35 +57,19 @@ class GpuMemoryBufferManager;
namespace content {
class CommandBufferProxyImpl;
class GpuChannelHost;
-
-class CONTENT_EXPORT GpuChannelHostFactory {
- public:
- virtual ~GpuChannelHostFactory() {}
-
- virtual bool IsMainThread() = 0;
- virtual scoped_refptr<base::SingleThreadTaskRunner>
- GetIOThreadTaskRunner() = 0;
- virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) = 0;
- virtual CreateCommandBufferResult CreateViewCommandBuffer(
- int32_t surface_id,
- const GPUCreateCommandBufferConfig& init_params,
- int32_t route_id) = 0;
-};
+class GpuChannelHostFactory;
+struct GpuCreateCommandBufferConfig;
// Encapsulates an IPC channel between the client and one GPU process.
// On the GPU process side there's a corresponding GpuChannel.
// Every method can be called on any thread with a message loop, except for the
// IO thread.
-class GpuChannelHost : public IPC::Sender,
- public base::RefCountedThreadSafe<GpuChannelHost> {
+class GpuChannelHost : public base::RefCountedThreadSafe<GpuChannelHost> {
public:
// Must be called on the main thread (as defined by the factory).
static scoped_refptr<GpuChannelHost> Create(
- GpuChannelHostFactory* factory,
- int channel_id,
+ scoped_ptr<GpuChannelHostIPCTransport> transport,
const gpu::GPUInfo& gpu_info,
- const IPC::ChannelHandle& channel_handle,
- base::WaitableEvent* shutdown_event,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager);
static const int32_t kDefaultStreamId = -1;
@@ -97,22 +77,17 @@ class GpuChannelHost : public IPC::Sender,
GpuStreamPriority::NORMAL;
bool IsLost() const {
- DCHECK(channel_filter_.get());
- return channel_filter_->IsLost();
+ DCHECK(transport_.get());
+ return transport_->IsLost();
}
- int channel_id() const { return channel_id_; }
-
// The GPU stats reported by the GPU process.
const gpu::GPUInfo& gpu_info() const { return gpu_info_; }
- // IPC::Sender implementation:
- bool Send(IPC::Message* msg) override;
-
// Set an ordering barrier. AsyncFlushes any pending barriers on other
// routes. Combines multiple OrderingBarriers into a single AsyncFlush.
// Returns the flush ID for the stream or 0 if put offset was not changed.
- uint32_t OrderingBarrier(int32_t route_id,
+ uint32_t OrderingBarrier(CommandBufferIPCTransport* transport,
int32_t stream_id,
int32_t put_offset,
uint32_t flush_count,
@@ -153,12 +128,6 @@ class GpuChannelHost : public IPC::Sender,
// destruction.
void DestroyChannel();
- // Add a route for the current message loop.
- void AddRoute(int route_id, base::WeakPtr<IPC::Listener> listener);
- void RemoveRoute(int route_id);
-
- GpuChannelHostFactory* factory() const { return factory_; }
-
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const {
return gpu_memory_buffer_manager_;
}
@@ -182,9 +151,6 @@ class GpuChannelHost : public IPC::Sender,
// Reserve one unused image ID.
int32_t ReserveImageId();
- // Generate a route ID guaranteed to be unique for this channel.
- int32_t GenerateRouteID();
-
// Generate a stream ID guaranteed to be unique for this channel.
int32_t GenerateStreamID();
@@ -204,52 +170,6 @@ class GpuChannelHost : public IPC::Sender,
private:
friend class base::RefCountedThreadSafe<GpuChannelHost>;
- // A filter used internally to route incoming messages from the IO thread
- // to the correct message loop. It also maintains some shared state between
- // all the contexts.
- class MessageFilter : public IPC::MessageFilter {
- public:
- MessageFilter();
-
- // Called on the IO thread.
- void AddRoute(int32_t route_id,
- base::WeakPtr<IPC::Listener> listener,
- scoped_refptr<base::SingleThreadTaskRunner> task_runner);
- // Called on the IO thread.
- void RemoveRoute(int32_t route_id);
-
- // IPC::MessageFilter implementation
- // (called on the IO thread):
- bool OnMessageReceived(const IPC::Message& msg) override;
- void OnChannelError() override;
-
- // The following methods can be called on any thread.
-
- // Whether the channel is lost.
- bool IsLost() const;
-
- private:
- struct ListenerInfo {
- ListenerInfo();
- ~ListenerInfo();
-
- base::WeakPtr<IPC::Listener> listener;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner;
- };
-
- ~MessageFilter() override;
-
- // Threading notes: |listeners_| is only accessed on the IO thread. Every
- // other field is protected by |lock_|.
- base::hash_map<int32_t, ListenerInfo> listeners_;
-
- // Protects all fields below this one.
- mutable base::Lock lock_;
-
- // Whether the channel has been lost.
- bool lost_;
- };
-
struct StreamFlushInfo {
StreamFlushInfo();
~StreamFlushInfo();
@@ -261,55 +181,37 @@ class GpuChannelHost : public IPC::Sender,
// These are local per context.
bool flush_pending;
- int32_t route_id;
+ // int32_t route_id;
+ CommandBufferIPCTransport* transport;
int32_t put_offset;
uint32_t flush_count;
uint32_t flush_id;
std::vector<ui::LatencyInfo> latency_info;
};
- GpuChannelHost(GpuChannelHostFactory* factory,
- int channel_id,
+ GpuChannelHost(scoped_ptr<GpuChannelHostIPCTransport> transport,
const gpu::GPUInfo& gpu_info,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager);
- ~GpuChannelHost() override;
- void Connect(const IPC::ChannelHandle& channel_handle,
- base::WaitableEvent* shutdown_event);
- bool InternalSend(IPC::Message* msg);
- void InternalFlush(StreamFlushInfo* flush_info);
+ ~GpuChannelHost();
- // Threading notes: all fields are constant during the lifetime of |this|
- // except:
- // - |next_image_id_|, atomic type
- // - |next_route_id_|, atomic type
- // - |next_stream_id_|, atomic type
- // - |channel_| and |stream_flush_info_|, protected by |context_lock_|
- GpuChannelHostFactory* const factory_;
+ void InternalFlush(StreamFlushInfo* flush_info);
- const int channel_id_;
const gpu::GPUInfo gpu_info_;
- scoped_refptr<MessageFilter> channel_filter_;
-
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
- // A filter for sending messages from thread other than the main thread.
- scoped_refptr<IPC::SyncMessageFilter> sync_filter_;
-
// Image IDs are allocated in sequence.
base::AtomicSequenceNumber next_image_id_;
- // Route IDs are allocated in sequence.
- base::AtomicSequenceNumber next_route_id_;
-
// Stream IDs are allocated in sequence.
base::AtomicSequenceNumber next_stream_id_;
// Protects channel_ and stream_flush_info_.
mutable base::Lock context_lock_;
- scoped_ptr<IPC::SyncChannel> channel_;
base::hash_map<int32_t, StreamFlushInfo> stream_flush_info_;
+ scoped_ptr<GpuChannelHostIPCTransport> transport_;
+
DISALLOW_COPY_AND_ASSIGN(GpuChannelHost);
};
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.cc ('k') | content/common/gpu/client/gpu_channel_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698