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

Unified Diff: content/common/gpu/media/gpu_arc_accelerator.h

Issue 1451353002: Implement GpuArcVideoService for arc video accelerator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/media/gpu_arc_accelerator.h
diff --git a/content/common/gpu/media/gpu_arc_accelerator.h b/content/common/gpu/media/gpu_arc_accelerator.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b7202c22e210eb3184c282291a2b0d397c65670
--- /dev/null
+++ b/content/common/gpu/media/gpu_arc_accelerator.h
@@ -0,0 +1,88 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_GPU_MEDIA_GPU_ARC_ACCELERATOR_H_
+#define CONTENT_COMMON_GPU_MEDIA_GPU_ARC_ACCELERATOR_H_
+
+#include <map>
+
+#include "base/memory/ref_counted.h"
+#include "base/threading/non_thread_safe.h"
+#include "base/threading/thread.h"
+#include "media/video/arc_video_accelerator.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+class WaitableEvent;
+}
+
+namespace IPC {
+struct ChannelHandle;
+}
+
+namespace content {
+class GpuChannel;
+
+// GpuArcAccelerator manages life-cycle and IPC message translation for
+// ArcVideoAccelerator.
+//
+// For each creation requests from GpuChannel, GpuArcAccelerator will create a
+// new IPC channel. All messages to ArcVideoAccelerator are handled on
+// |arc_accelerator_thread_|.
+class GpuArcAccelerator : public base::NonThreadSafe {
Owen Lin 2015/11/26 03:54:41 How about refactor this class into two seperate cl
kcwu 2015/11/26 10:34:42 The latter responsibility is called "Client" (a ba
+ public:
+ class Client;
+
+ // |gpu_channel| is used to send reply message for CreateClient.
+ // |shutdown_event| should signal an event when this process shutdown in
+ // order to notify our new IPC channel to terminate.
+ GpuArcAccelerator(
+ GpuChannel* gpu_channel,
+ base::WaitableEvent* shutdown_event,
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
+
+ // Upon deletion, all ArcVideoAccelerator will be deleted and the associated
+ // IPC channels are closed.
+ ~GpuArcAccelerator();
+
+ void Initialize();
+
+ // Creates a new client and initalize with |device_type|. The creation
+ // result, as an IPC message, will be send back via |gpu_channel_|.
+ void CreateClient(uint32_t device_type);
+
+ // Removes the reference of |client| (and trigger deletion) from this class.
+ void RemoveClientOnArcThread(Client* client);
+
+ private:
+ void CreateClientOnArcThread(uint32_t device_type);
+ void RemoveAllClientsOnArcThread(base::WaitableEvent* done);
+
+ // GpuChannel outlives this class. So a raw pointer is safe.
+ GpuChannel* gpu_channel_;
+
+ // Shutdown event of GPU process.
+ base::WaitableEvent* shutdown_event_;
+
+ // GPU io thread task runner.
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+
+ // GPU main thread task runner.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ // Arc accelerator thread.
+ base::Thread arc_accelerator_thread_;
+
+ // Arc accelerator task runner.
+ scoped_refptr<base::SingleThreadTaskRunner> arc_task_runner_;
+
+ // Bookkeeping all clients. Only accessed on arc thread.
+ std::map<Client*, scoped_ptr<Client>> clients_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(GpuArcAccelerator);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_MEDIA_GPU_ARC_ACCELERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698