Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / media / device_request_message_filter.h
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_DEVICE_REQUEST_MESSAGE_FILTER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_DEVICE_REQUEST_MESSAGE_FILTER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/synchronization/lock.h"
12 #include "content/browser/renderer_host/media/media_stream_requester.h"
13 #include "content/common/content_export.h"
14 #include "content/public/browser/browser_message_filter.h"
15
16 namespace content {
17
18 class MediaStreamManager;
19 class ResourceContext;
20
21 // DeviceRequestMessageFilter used to delegate requests from the
22 // MediaStreamCenter.
23 class CONTENT_EXPORT DeviceRequestMessageFilter : public BrowserMessageFilter,
24                                                   public MediaStreamRequester {
25  public:
26   DeviceRequestMessageFilter(ResourceContext* resource_context,
27                              MediaStreamManager* media_stream_manager,
28                              int render_process_id);
29
30   // MediaStreamRequester implementation.
31   // TODO(vrk): Replace MediaStreamRequester interface with a single callback so
32   // we don't have to override all these callbacks we don't care about.
33   // (crbug.com/249476)
34   virtual void StreamGenerated(
35       int render_frame_id, int page_request_id, const std::string& label,
36       const StreamDeviceInfoArray& audio_devices,
37       const StreamDeviceInfoArray& video_devices) OVERRIDE {}
38   virtual void StreamGenerationFailed(
39       int render_frame_id,
40       int page_request_id,
41       content::MediaStreamRequestResult result) OVERRIDE {}
42   virtual void DeviceStopped(int render_frame_id,
43                              const std::string& label,
44                              const StreamDeviceInfo& device) OVERRIDE {}
45   virtual void DeviceOpened(int render_frame_id,
46                             int page_request_id,
47                             const std::string& label,
48                             const StreamDeviceInfo& video_device) OVERRIDE {}
49   // DevicesEnumerated() is the only callback we're interested in.
50   virtual void DevicesEnumerated(int render_frame_id,
51                                  int page_request_id,
52                                  const std::string& label,
53                                  const StreamDeviceInfoArray& devices) OVERRIDE;
54
55   // BrowserMessageFilter implementation.
56   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
57   virtual void OnChannelClosing() OVERRIDE;
58
59  protected:
60   virtual ~DeviceRequestMessageFilter();
61
62  private:
63   void OnGetSources(int request_id, const GURL& security_origin);
64
65   // Owned by ProfileIOData which is guaranteed to outlive DRMF.
66   ResourceContext* resource_context_;
67   MediaStreamManager* media_stream_manager_;
68
69   struct DeviceRequest;
70   typedef std::vector<DeviceRequest> DeviceRequestList;
71   // List of all requests.
72   DeviceRequestList requests_;
73
74   int render_process_id_;
75
76   DISALLOW_COPY_AND_ASSIGN(DeviceRequestMessageFilter);
77 };
78
79 }  // namespace content
80
81 #endif  // CONTENT_BROWSER_RENDERER_HOST_MEDIA_DEVICE_REQUEST_MESSAGE_FILTER_H_