Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / renderer_host / media / media_stream_dispatcher_host.h
blobf34054e8d318200a6b8e2c421f0bb1c2045eaa14
1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_
8 #include <map>
9 #include <string>
10 #include <utility>
12 #include "content/browser/renderer_host/media/media_stream_manager.h"
13 #include "content/browser/renderer_host/media/media_stream_requester.h"
14 #include "content/common/content_export.h"
15 #include "content/common/media/media_stream_options.h"
16 #include "content/public/browser/browser_message_filter.h"
17 #include "content/public/browser/resource_context.h"
19 namespace content {
21 class MediaStreamManager;
23 // MediaStreamDispatcherHost is a delegate for Media Stream API messages used by
24 // MediaStreamImpl. It's the complement of MediaStreamDispatcher
25 // (owned by RenderView).
26 class CONTENT_EXPORT MediaStreamDispatcherHost : public BrowserMessageFilter,
27 public MediaStreamRequester {
28 public:
29 MediaStreamDispatcherHost(
30 int render_process_id,
31 const ResourceContext::SaltCallback& salt_callback,
32 MediaStreamManager* media_stream_manager);
34 // MediaStreamRequester implementation.
35 virtual void StreamGenerated(
36 int render_view_id,
37 int page_request_id,
38 const std::string& label,
39 const StreamDeviceInfoArray& audio_devices,
40 const StreamDeviceInfoArray& video_devices) OVERRIDE;
41 virtual void StreamGenerationFailed(
42 int render_view_id,
43 int page_request_id,
44 content::MediaStreamRequestResult result) OVERRIDE;
45 virtual void DeviceStopped(int render_view_id,
46 const std::string& label,
47 const StreamDeviceInfo& device) OVERRIDE;
48 virtual void DevicesEnumerated(int render_view_id,
49 int page_request_id,
50 const std::string& label,
51 const StreamDeviceInfoArray& devices) OVERRIDE;
52 virtual void DeviceOpened(int render_view_id,
53 int page_request_id,
54 const std::string& label,
55 const StreamDeviceInfo& video_device) OVERRIDE;
57 // BrowserMessageFilter implementation.
58 virtual bool OnMessageReceived(const IPC::Message& message,
59 bool* message_was_ok) OVERRIDE;
60 virtual void OnChannelClosing() OVERRIDE;
62 protected:
63 virtual ~MediaStreamDispatcherHost();
65 private:
66 friend class MockMediaStreamDispatcherHost;
68 void OnGenerateStream(int render_view_id,
69 int page_request_id,
70 const StreamOptions& components,
71 const GURL& security_origin,
72 bool user_gesture);
73 void OnCancelGenerateStream(int render_view_id,
74 int page_request_id);
75 void OnStopStreamDevice(int render_view_id,
76 const std::string& device_id);
78 void OnEnumerateDevices(int render_view_id,
79 int page_request_id,
80 MediaStreamType type,
81 const GURL& security_origin);
83 void OnCancelEnumerateDevices(int render_view_id,
84 int page_request_id);
86 void OnOpenDevice(int render_view_id,
87 int page_request_id,
88 const std::string& device_id,
89 MediaStreamType type,
90 const GURL& security_origin);
92 void OnCloseDevice(int render_view_id,
93 const std::string& label);
95 void StoreRequest(int render_view_id,
96 int page_request_id,
97 const std::string& label);;
99 bool IsURLAllowed(const GURL& url);
101 int render_process_id_;
102 ResourceContext::SaltCallback salt_callback_;
103 MediaStreamManager* media_stream_manager_;
105 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcherHost);
108 } // namespace content
110 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_