OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/callback.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "content/public/common/media_stream_request.h" | |
13 | |
14 namespace content { | |
15 | |
16 // MediaStreamUIProxy proxies calls to media stream UI between IO thread and UI | |
17 // thread. One instance of this class is create per MediaStream object. It must | |
18 // be create, used and destroyed on IO thread. | |
19 class CONTENT_EXPORT MediaStreamUIProxy { | |
20 public: | |
21 typedef base::Callback< | |
22 void (const MediaStreamDevices& devices)> ResponseCallback; | |
23 | |
24 explicit MediaStreamUIProxy(); | |
tommi (sloooow) - chröme
2013/04/22 13:22:39
remove explicit
Sergey Ulanov
2013/04/23 05:21:44
Done.
| |
25 virtual ~MediaStreamUIProxy(); | |
26 | |
27 // Requests access for the MediaStream by calling | |
28 // WebContentsDelegate::RequestMediaAccessPermission(). The specified | |
29 // |response_callback| is called when the WebContentsDelegate approves or | |
30 // denies request. | |
31 virtual void RequestAccess(const MediaStreamRequest& request, | |
32 const ResponseCallback& response_callback); | |
33 | |
34 // Notifies the UI that the MediaStream has been started. Must be called after | |
35 // access has been approved using RequestAccess(). |stop_callback| is be | |
36 // called on the IO thread after the user has requests the stream to be | |
37 // stopped. | |
38 virtual void OnStarted(const base::Closure& stop_callback); | |
39 | |
40 private: | |
41 class Core; | |
42 friend class Core; | |
43 friend class FakeMediaStreamUIProxy; | |
44 | |
45 void ProcessAccessRequestResponse(const MediaStreamDevices& devices); | |
46 void ProcessStopRequestFromUI(); | |
47 | |
48 scoped_ptr<Core> core_; | |
49 ResponseCallback response_callback_; | |
50 base::Closure stop_callback_; | |
51 | |
52 base::WeakPtrFactory<MediaStreamUIProxy> weak_factory_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(MediaStreamUIProxy); | |
55 }; | |
56 | |
57 class CONTENT_EXPORT FakeMediaStreamUIProxy : public MediaStreamUIProxy { | |
58 public: | |
59 explicit FakeMediaStreamUIProxy(); | |
60 virtual ~FakeMediaStreamUIProxy(); | |
61 | |
62 virtual void RequestAccess( | |
63 const MediaStreamRequest& request, | |
64 const ResponseCallback& response_callback) OVERRIDE; | |
65 virtual void OnStarted(const base::Closure& stop_callback) OVERRIDE; | |
66 | |
67 private: | |
68 DISALLOW_COPY_AND_ASSIGN(FakeMediaStreamUIProxy); | |
69 }; | |
70 | |
71 } // namespace content | |
72 | |
73 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ | |
OLD | NEW |