Chromium Code Reviews| 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 class RenderViewHostDelegate; | |
| 17 | |
| 18 // MediaStreamUIProxy proxies calls to media stream UI between IO thread and UI | |
| 19 // thread. One instance of this class is create per MediaStream object. It must | |
| 20 // be create, used and destroyed on IO thread. | |
| 21 class CONTENT_EXPORT MediaStreamUIProxy { | |
| 22 public: | |
| 23 typedef base::Callback< | |
| 24 void (const MediaStreamDevices& devices)> ResponseCallback; | |
| 25 | |
| 26 static scoped_ptr<MediaStreamUIProxy> Create(); | |
| 27 static scoped_ptr<MediaStreamUIProxy> CreateForTests( | |
| 28 RenderViewHostDelegate* render_delegate); | |
| 29 | |
| 30 virtual ~MediaStreamUIProxy(); | |
| 31 | |
| 32 // Requests access for the MediaStream by calling | |
| 33 // WebContentsDelegate::RequestMediaAccessPermission(). The specified | |
| 34 // |response_callback| is called when the WebContentsDelegate approves or | |
| 35 // denies request. | |
| 36 virtual void RequestAccess(const MediaStreamRequest& request, | |
| 37 const ResponseCallback& response_callback); | |
| 38 | |
| 39 // Notifies the UI that the MediaStream has been started. Must be called after | |
| 40 // access has been approved using RequestAccess(). |stop_callback| is be | |
| 41 // called on the IO thread after the user has requests the stream to be | |
| 42 // stopped. | |
| 43 virtual void OnStarted(const base::Closure& stop_callback); | |
| 44 | |
| 45 void SetRenderViewHostDelegateForTests(RenderViewHostDelegate* delegate); | |
| 46 | |
| 47 protected: | |
| 48 MediaStreamUIProxy(RenderViewHostDelegate* test_render_delegate); | |
| 49 | |
| 50 private: | |
| 51 class Core; | |
| 52 friend class Core; | |
| 53 friend class FakeMediaStreamUIProxy; | |
| 54 | |
| 55 void ProcessAccessRequestResponse(const MediaStreamDevices& devices); | |
| 56 void ProcessStopRequestFromUI(); | |
| 57 | |
| 58 RenderViewHostDelegate* renderer_delegate_; | |
|
miu
2013/06/06 23:05:23
nit: Rename to test_render_delegate_ for clarity,
Sergey Ulanov
2013/06/07 00:37:09
removed this member - it wasn't used anyway.
| |
| 59 | |
| 60 scoped_ptr<Core> core_; | |
| 61 ResponseCallback response_callback_; | |
| 62 base::Closure stop_callback_; | |
| 63 | |
| 64 base::WeakPtrFactory<MediaStreamUIProxy> weak_factory_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(MediaStreamUIProxy); | |
| 67 }; | |
| 68 | |
| 69 class CONTENT_EXPORT FakeMediaStreamUIProxy : public MediaStreamUIProxy { | |
| 70 public: | |
| 71 explicit FakeMediaStreamUIProxy(); | |
| 72 virtual ~FakeMediaStreamUIProxy(); | |
| 73 | |
| 74 void SetAvailableDevices(const MediaStreamDevices& devices); | |
| 75 | |
| 76 // MediaStreamUIProxy overrides. | |
| 77 virtual void RequestAccess( | |
| 78 const MediaStreamRequest& request, | |
| 79 const ResponseCallback& response_callback) OVERRIDE; | |
| 80 virtual void OnStarted(const base::Closure& stop_callback) OVERRIDE; | |
| 81 | |
| 82 private: | |
| 83 MediaStreamDevices devices_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(FakeMediaStreamUIProxy); | |
| 86 }; | |
| 87 | |
| 88 } // namespace content | |
| 89 | |
| 90 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_PROXY_H_ | |
| OLD | NEW |