Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // MediaPermission implementation which dispatches queries/requests to Mojo | |
| 6 // PermissionService. It relies on its base class MediaPermissionDispatcher to | |
| 7 // manage pending callbacks. Non-UI threads could create | |
| 8 // MediaPermissionDispatcherProxy by calling CreateProxy such that calls will be | |
| 9 // executed on the UI thread which is where this object lives. | |
| 10 | |
| 11 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_ | |
| 12 #define CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_ | |
| 13 | |
| 14 #include <map> | |
| 15 | |
| 16 #include "base/single_thread_task_runner.h" | |
| 17 #include "base/threading/thread_checker.h" | |
| 18 #include "content/common/content_export.h" | |
| 19 #include "content/common/permission_service.mojom.h" | |
| 20 #include "content/public/renderer/render_frame_observer.h" | |
| 21 #include "content/renderer/media/media_permission_dispatcher.h" | |
| 22 #include "media/base/media_permission.h" | |
| 23 | |
| 24 namespace content { | |
| 25 | |
| 26 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
| |
| 27 : public MediaPermissionDispatcher, | |
| 28 public RenderFrameObserver { | |
| 29 public: | |
| 30 explicit MediaPermissionDispatcherImpl(RenderFrame* render_frame); | |
| 31 ~MediaPermissionDispatcherImpl() override; | |
| 32 | |
| 33 // media::MediaPermission implementation. | |
| 34 void HasPermission(Type type, | |
| 35 const GURL& security_origin, | |
| 36 const PermissionStatusCB& permission_status_cb) override; | |
| 37 void RequestPermission( | |
| 38 Type type, | |
| 39 const GURL& security_origin, | |
| 40 const PermissionStatusCB& permission_status_cb) override; | |
| 41 | |
| 42 // Create MediaPermissionDispatcherProxy object which will dispatch the | |
| 43 // callback between the |caller_task_runner| and |task_runner_| in a thread | |
| 44 // safe way. This can be called from non-UI thread. | |
| 45 scoped_ptr<media::MediaPermission> CreateProxy( | |
| 46 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner); | |
| 47 | |
| 48 private: | |
| 49 // Callback for |permission_service_| calls. | |
| 50 void OnPermissionStatus(uint32_t request_id, PermissionStatus status); | |
| 51 | |
| 52 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 53 | |
| 54 PermissionServicePtr permission_service_; | |
| 55 | |
| 56 base::ThreadChecker thread_checker_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(MediaPermissionDispatcherImpl); | |
| 59 }; | |
| 60 | |
| 61 } // namespace content | |
| 62 | |
| 63 #endif // CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_ | |
| OLD | NEW |