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 // A helper class to forward the calls to MediaPermissionDispatcherImpl on UI | |
6 // thread and have the permission status callback on the caller's original | |
7 // non-UI thread. | |
8 | |
9 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_PROXY_H_ | |
10 #define CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_PROXY_H_ | |
11 | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "base/single_thread_task_runner.h" | |
14 #include "content/common/content_export.h" | |
15 #include "content/renderer/media/media_permission_dispatcher.h" | |
16 #include "media/base/media_permission.h" | |
17 | |
18 namespace content { | |
19 | |
20 class CONTENT_EXPORT MediaPermissionDispatcherProxy | |
21 : public MediaPermissionDispatcher { | |
22 public: | |
23 // |ui_task_runner| must be the UI thread. It will be used to call into the | |
24 // |media_permission| which is the MediaPermissionDispatcherImpl. | |
25 MediaPermissionDispatcherProxy( | |
26 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | |
27 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | |
28 base::WeakPtr<MediaPermissionDispatcher> media_permission); | |
29 | |
30 ~MediaPermissionDispatcherProxy() override; | |
31 | |
32 // MediaPermission implementation. | |
33 void HasPermission(Type type, | |
34 const GURL& security_origin, | |
35 const PermissionStatusCB& permission_status_cb) override; | |
36 | |
37 void RequestPermission( | |
38 Type type, | |
39 const GURL& security_origin, | |
40 const PermissionStatusCB& permission_status_cb) override; | |
41 | |
42 private: | |
43 class Core; | |
44 | |
45 void ReportResult(bool result); | |
46 | |
47 scoped_ptr<Core> core_; | |
48 | |
49 base::WeakPtrFactory<MediaPermissionDispatcherProxy> weak_ptr_factory_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(MediaPermissionDispatcherProxy); | |
52 }; | |
53 | |
54 } // namespace content | |
55 | |
56 #endif // CONTENT_RENDERER_MEDIA_MEDIA_PERMISSION_PROXY_H_ | |
OLD | NEW |