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

Unified Diff: components/mus/common/gpu_service.h

Issue 2087333002: mus::GpuService: Support establish GpuChannel asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the unittests Created 4 years, 6 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
« no previous file with comments | « ash/sysui/sysui_application.cc ('k') | components/mus/common/gpu_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/common/gpu_service.h
diff --git a/components/mus/common/gpu_service.h b/components/mus/common/gpu_service.h
index 1ecb979161bc12963fa4d5902c1a0e115259d9a5..a3d5cd106f6dba04aab40856024b7f1693a54765 100644
--- a/components/mus/common/gpu_service.h
+++ b/components/mus/common/gpu_service.h
@@ -14,7 +14,9 @@
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
+#include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
#include "components/mus/common/mus_common_export.h"
+#include "components/mus/public/interfaces/gpu_service.mojom.h"
#include "gpu/ipc/client/gpu_channel_host.h"
namespace shell {
@@ -23,22 +25,39 @@ class Connector;
namespace mus {
-class MojoGpuMemoryBufferManager;
-
class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory {
public:
- scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannel(
- shell::Connector* connector);
+ void EstablishGpuChannel(const base::Closure& callback);
+ scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync();
+ scoped_refptr<gpu::GpuChannelHost> GetGpuChannel();
+ gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const {
+ return gpu_memory_buffer_manager_.get();
+ }
static bool UseChromeGpuCommandBuffer();
+
+ // The GpuService has to be initialized in the main thread before establishing
+ // the gpu channel.
+ static void Initialize(shell::Connector* connector);
+ // The GpuService has to be terminated in the main thread.
+ static void Terminate();
static GpuService* GetInstance();
private:
friend struct base::DefaultSingletonTraits<GpuService>;
- GpuService();
+ explicit GpuService(shell::Connector* connector);
~GpuService() override;
+ scoped_refptr<gpu::GpuChannelHost> GetGpuChannelLocked();
+ void EstablishGpuChannelOnMainThread();
+ void EstablishGpuChannelOnMainThreadSyncLocked();
+ void EstablishGpuChannelOnMainThreadDone(
+ bool locked,
+ int client_id,
+ mojom::ChannelHandlePtr channel_handle,
+ mojom::GpuInfoPtr gpu_info);
+
// gpu::GpuChannelHostFactory overrides:
bool IsMainThread() override;
scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
@@ -46,13 +65,18 @@ class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory {
size_t size) override;
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
+ shell::Connector* connector_;
base::WaitableEvent shutdown_event_;
base::Thread io_thread_;
std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_;
- // Lock for |gpu_channel_|.
+ // Lock for |gpu_channel_|, |establish_callbacks_| & |is_establishing_|.
base::Lock lock_;
+ bool is_establishing_;
+ mus::mojom::GpuServicePtr gpu_service_;
scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
+ std::vector<base::Closure> establish_callbacks_;
+ base::ConditionVariable establishing_condition_;
DISALLOW_COPY_AND_ASSIGN(GpuService);
};
« no previous file with comments | « ash/sysui/sysui_application.cc ('k') | components/mus/common/gpu_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698