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

Unified Diff: content/renderer/media/media_permission_dispatcher_impl.h

Issue 1351443005: Refactor media permission dispatcher class and create proxy class for non-UI threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/renderer/media/media_permission_dispatcher_impl.h
diff --git a/content/renderer/media/media_permission_dispatcher_impl.h b/content/renderer/media/media_permission_dispatcher_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..acc4730a4a4057d8f69446b34684ebdd373b8635
--- /dev/null
+++ b/content/renderer/media/media_permission_dispatcher_impl.h
@@ -0,0 +1,63 @@
+// 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.
+
+// MediaPermission implementation which dispatches queries/requests to Mojo
+// PermissionService. It relies on its base class MediaPermissionDispatcher to
+// manage pending callbacks. Non-UI threads could create
+// MediaPermissionDispatcherProxy by calling CreateProxy such that calls will be
+// executed on the UI thread which is where this object lives.
+
+#ifndef CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_
+#define CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_
+
+#include <map>
+
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_checker.h"
+#include "content/common/content_export.h"
+#include "content/common/permission_service.mojom.h"
+#include "content/public/renderer/render_frame_observer.h"
+#include "content/renderer/media/media_permission_dispatcher.h"
+#include "media/base/media_permission.h"
+
+namespace content {
+
+class CONTENT_EXPORT MediaPermissionDispatcherImpl
perkj_chrome 2015/09/22 08:24:16 Why do you need this extra level? I understand you
guoweis_left_chromium 2015/09/22 18:48:49 The MediaPermissionDispatcherImpl takes render_fra
+ : public MediaPermissionDispatcher,
+ public RenderFrameObserver {
+ public:
+ explicit MediaPermissionDispatcherImpl(RenderFrame* render_frame);
+ ~MediaPermissionDispatcherImpl() override;
+
+ // media::MediaPermission implementation.
+ void HasPermission(Type type,
+ const GURL& security_origin,
+ const PermissionStatusCB& permission_status_cb) override;
+ void RequestPermission(
+ Type type,
+ const GURL& security_origin,
+ const PermissionStatusCB& permission_status_cb) override;
+
+ // Create MediaPermissionDispatcherProxy object which will dispatch the
+ // callback between the |caller_task_runner| and |task_runner_| in a thread
+ // safe way. This can be called from non-UI thread.
+ scoped_ptr<media::MediaPermission> CreateProxy(
+ scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner);
+
+ private:
+ // Callback for |permission_service_| calls.
+ void OnPermissionStatus(uint32_t request_id, PermissionStatus status);
+
+ const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+
+ PermissionServicePtr permission_service_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaPermissionDispatcherImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698