Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/media/media_internals.h

Issue 12153002: Move chrome://media-internals to content. This allows us to hide implementation details from the pu… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_
6 #define CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/singleton.h"
12 #include "base/observer_list.h"
13 #include "base/values.h"
14 #include "content/public/browser/media_observer.h"
15 #include "content/public/common/media_stream_request.h"
16
17 class MediaCaptureDevicesDispatcher;
18 class MediaInternalsObserver;
19 class MediaStreamCaptureIndicator;
20 class Profile;
21
22 namespace media {
23
24 struct MediaLogEvent;
25
26 // Helper to get the default devices which can be used by the media request,
27 // if the return list is empty, it means there is no available device on the OS.
28 // Called on the UI thread.
29 void GetDefaultDevicesForProfile(Profile* profile,
30 bool audio,
31 bool video,
32 content::MediaStreamDevices* devices);
33
34 // Helper for picking the device that was requested for an OpenDevice request.
35 // If the device requested is not available it will revert to using the first
36 // available one instead or will return an empty list if no devices of the
37 // requested kind are present.
38 void GetRequestedDevice(const std::string& requested_device_id,
39 bool audio,
40 bool video,
41 content::MediaStreamDevices* devices);
42 }
43
44 // This class stores information about currently active media.
45 // It's constructed on the UI thread but all of its methods are called on the IO
46 // thread.
47 class MediaInternals : public content::MediaObserver {
48 public:
49 virtual ~MediaInternals();
50
51 static MediaInternals* GetInstance();
52
53 // Overridden from content::MediaObserver:
54 virtual void OnDeleteAudioStream(void* host, int stream_id) OVERRIDE;
55 virtual void OnSetAudioStreamPlaying(void* host,
56 int stream_id,
57 bool playing) OVERRIDE;
58 virtual void OnSetAudioStreamStatus(void* host,
59 int stream_id,
60 const std::string& status) OVERRIDE;
61 virtual void OnSetAudioStreamVolume(void* host,
62 int stream_id,
63 double volume) OVERRIDE;
64 virtual void OnMediaEvent(int render_process_id,
65 const media::MediaLogEvent& event) OVERRIDE;
66 virtual void OnCaptureDevicesOpened(
67 int render_process_id,
68 int render_view_id,
69 const content::MediaStreamDevices& devices) OVERRIDE;
70 virtual void OnCaptureDevicesClosed(
71 int render_process_id,
72 int render_view_id,
73 const content::MediaStreamDevices& devices) OVERRIDE;
74 virtual void OnAudioCaptureDevicesChanged(
75 const content::MediaStreamDevices& devices) OVERRIDE;
76 virtual void OnVideoCaptureDevicesChanged(
77 const content::MediaStreamDevices& devices) OVERRIDE;
78 virtual void OnMediaRequestStateChanged(
79 int render_process_id,
80 int render_view_id,
81 const content::MediaStreamDevice& device,
82 content::MediaRequestState state) OVERRIDE;
83
84 // Methods for observers.
85 // Observers should add themselves on construction and remove themselves
86 // on destruction.
87 void AddObserver(MediaInternalsObserver* observer);
88 void RemoveObserver(MediaInternalsObserver* observer);
89 void SendEverything();
90
91 scoped_refptr<MediaStreamCaptureIndicator> GetMediaStreamCaptureIndicator();
92 scoped_refptr<MediaCaptureDevicesDispatcher>
93 GetMediaCaptureDevicesDispatcher();
94
95 private:
96 friend class MediaInternalsTest;
97 friend struct DefaultSingletonTraits<MediaInternals>;
98
99 MediaInternals();
100
101 // Sets |property| of an audio stream to |value| and notifies observers.
102 // (host, stream_id) is a unique id for the audio stream.
103 // |host| will never be dereferenced.
104 void UpdateAudioStream(void* host, int stream_id,
105 const std::string& property, Value* value);
106
107 // Removes |item| from |data_|.
108 void DeleteItem(const std::string& item);
109
110 // Sets data_.id.property = value and notifies attached UIs using update_fn.
111 // id may be any depth, e.g. "video.decoders.1.2.3"
112 void UpdateItem(const std::string& update_fn, const std::string& id,
113 const std::string& property, Value* value);
114
115 // Calls javascript |function|(|value|) on each attached UI.
116 void SendUpdate(const std::string& function, Value* value);
117
118 DictionaryValue data_;
119 ObserverList<MediaInternalsObserver> observers_;
120 scoped_refptr<MediaStreamCaptureIndicator> media_stream_capture_indicator_;
121 scoped_refptr<MediaCaptureDevicesDispatcher> media_devices_dispatcher_;
122
123 DISALLOW_COPY_AND_ASSIGN(MediaInternals);
124 };
125
126 #endif // CHROME_BROWSER_MEDIA_MEDIA_INTERNALS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698