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

Side by Side Diff: content/renderer/media/media_permission_dispatcher_impl.h

Issue 1464183002: media: Simplify MediaPermissionDispatcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 4 years, 10 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 unified diff | Download patch
OLDNEW
(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 <stdint.h>
15
16 #include <map>
17
18 #include "base/macros.h"
19 #include "base/single_thread_task_runner.h"
20 #include "base/threading/thread_checker.h"
21 #include "content/common/content_export.h"
22 #include "content/common/permission_service.mojom.h"
23 #include "content/public/renderer/render_frame_observer.h"
24 #include "content/renderer/media/media_permission_dispatcher.h"
25 #include "media/base/media_permission.h"
26
27 namespace content {
28
29 class CONTENT_EXPORT MediaPermissionDispatcherImpl
30 : public MediaPermissionDispatcher,
31 public RenderFrameObserver {
32 public:
33 explicit MediaPermissionDispatcherImpl(RenderFrame* render_frame);
34 ~MediaPermissionDispatcherImpl() override;
35
36 // media::MediaPermission implementation.
37 void HasPermission(Type type,
38 const GURL& security_origin,
39 const PermissionStatusCB& permission_status_cb) override;
40
41 // MediaStreamDevicePermissionContext doesn't support RequestPermission yet
42 // and will always return CONTENT_SETTING_BLOCK.
43 void RequestPermission(
44 Type type,
45 const GURL& security_origin,
46 const PermissionStatusCB& permission_status_cb) override;
47
48 // Create MediaPermissionDispatcherProxy object which will dispatch the
49 // callback between the |caller_task_runner| and |task_runner_| in a thread
50 // safe way. This can be called from non-UI thread.
51 scoped_ptr<media::MediaPermission> CreateProxy(
52 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner);
53
54 private:
55 // Callback for |permission_service_| calls.
56 void OnPermissionStatus(uint32_t request_id, PermissionStatus status);
57
58 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
59
60 PermissionServicePtr permission_service_;
61
62 base::WeakPtrFactory<MediaPermissionDispatcherImpl> weak_ptr_factory_;
63
64 DISALLOW_COPY_AND_ASSIGN(MediaPermissionDispatcherImpl);
65 };
66
67 } // namespace content
68
69 #endif // CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_DISPATCHER_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_permission_dispatcher.cc ('k') | content/renderer/media/media_permission_dispatcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698