Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / renderer_host / media / media_stream_dispatcher_host.h
blob0ef6defdcba7e65c37ae63cff4a871c1cc51c583
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;
22 class ResourceContext;
24 // MediaStreamDispatcherHost is a delegate for Media Stream API messages used by
25 // MediaStreamImpl. There is one MediaStreamDispatcherHost per
26 // RenderProcessHost, the former owned by the latter.
27 class CONTENT_EXPORT MediaStreamDispatcherHost : public BrowserMessageFilter,
28 public MediaStreamRequester {
29 public:
30 MediaStreamDispatcherHost(
31 int render_process_id,
32 const ResourceContext::SaltCallback& salt_callback,
33 MediaStreamManager* media_stream_manager,
34 ResourceContext* resource_context);
36 // MediaStreamRequester implementation.
37 virtual void StreamGenerated(
38 int render_frame_id,
39 int page_request_id,
40 const std::string& label,
41 const StreamDeviceInfoArray& audio_devices,
42 const StreamDeviceInfoArray& video_devices) OVERRIDE;
43 virtual void StreamGenerationFailed(
44 int render_frame_id,
45 int page_request_id,
46 content::MediaStreamRequestResult result) OVERRIDE;
47 virtual void DeviceStopped(int render_frame_id,
48 const std::string& label,
49 const StreamDeviceInfo& device) OVERRIDE;
50 virtual void DevicesEnumerated(int render_frame_id,
51 int page_request_id,
52 const std::string& label,
53 const StreamDeviceInfoArray& devices) OVERRIDE;
54 virtual void DeviceOpened(int render_frame_id,
55 int page_request_id,
56 const std::string& label,
57 const StreamDeviceInfo& video_device) OVERRIDE;
59 // BrowserMessageFilter implementation.
60 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
61 virtual void OnChannelClosing() OVERRIDE;
63 protected:
64 virtual ~MediaStreamDispatcherHost();
66 private:
67 friend class MockMediaStreamDispatcherHost;
69 void OnGenerateStream(int render_frame_id,
70 int page_request_id,
71 const StreamOptions& components,
72 const GURL& security_origin,
73 bool user_gesture);
74 void OnCancelGenerateStream(int render_frame_id,
75 int page_request_id);
76 void OnStopStreamDevice(int render_frame_id,
77 const std::string& device_id);
79 void OnEnumerateDevices(int render_frame_id,
80 int page_request_id,
81 MediaStreamType type,
82 const GURL& security_origin);
84 void OnCancelEnumerateDevices(int render_frame_id,
85 int page_request_id);
87 void OnOpenDevice(int render_frame_id,
88 int page_request_id,
89 const std::string& device_id,
90 MediaStreamType type,
91 const GURL& security_origin);
93 void OnCloseDevice(int render_frame_id,
94 const std::string& label);
96 void StoreRequest(int render_frame_id,
97 int page_request_id,
98 const std::string& label);
100 bool IsURLAllowed(const GURL& url);
102 int render_process_id_;
103 ResourceContext::SaltCallback salt_callback_;
104 MediaStreamManager* media_stream_manager_;
106 // Owned by ProfileIOData which is guaranteed to outlive MSDH.
107 ResourceContext* const resource_context_;
109 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcherHost);
112 } // namespace content
114 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_