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

Unified Diff: content/renderer/media/media_permission_dispatcher.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: Fix windows build break. 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/media_permission_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/media_permission_dispatcher.h
diff --git a/content/renderer/media/media_permission_dispatcher.h b/content/renderer/media/media_permission_dispatcher.h
index 4e23bd717c912f6382a65f0758f0d62611fbe757..701afe6d088987a5c94754a1a0cd396ab1a13f11 100644
--- a/content/renderer/media/media_permission_dispatcher.h
+++ b/content/renderer/media/media_permission_dispatcher.h
@@ -2,48 +2,46 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Base class for MediaPermission implementations in content. This class allows
+// multiple pending PermissionService calls by managing callbacks for its
+// subclasses. This class is not thread safe and should only be used on one
+// thread.
+
#ifndef CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_H_
#define CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_H_
#include <map>
+#include "base/memory/weak_ptr.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 "media/base/media_permission.h"
namespace content {
-// MediaPermission implementation in content. This class is not thread safe
-// and should only be used on one thread.
-class CONTENT_EXPORT MediaPermissionDispatcher : public media::MediaPermission,
- public RenderFrameObserver {
+class CONTENT_EXPORT MediaPermissionDispatcher : public media::MediaPermission {
public:
- explicit MediaPermissionDispatcher(RenderFrame* render_frame);
+ MediaPermissionDispatcher();
~MediaPermissionDispatcher() 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;
+ protected:
+ // Register callbacks for PermissionService calls.
+ uint32_t RegisterCallback(const PermissionStatusCB& permission_status_cb);
+
+ // Deliver the permission status |granted| to the callback identified by
+ // |request_id|.
+ void DeliverResult(uint32_t request_id, bool granted);
+
+ base::ThreadChecker& thread_checker() { return thread_checker_; }
private:
// Map of request IDs and pending PermissionStatusCBs.
typedef std::map<uint32_t, PermissionStatusCB> RequestMap;
- // Callback for |permission_service_| calls.
- void OnPermissionStatus(uint32_t request_id, PermissionStatus status);
+ base::ThreadChecker thread_checker_;
uint32_t next_request_id_;
RequestMap requests_;
- PermissionServicePtr permission_service_;
-
- base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(MediaPermissionDispatcher);
};
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/media_permission_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698