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

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

Issue 11273060: Change MediaStreamCaptureIndicator back to ref counted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 1 month 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/media/media_internals.h" 5 #include "chrome/browser/media/media_internals.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/browser/media/media_internals_observer.h" 10 #include "chrome/browser/media/media_internals_observer.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 dict.SetDouble("time", event.time.ToDoubleT()); 62 dict.SetDouble("time", event.time.ToDoubleT());
63 dict.Set("params", event.params.DeepCopy()); 63 dict.Set("params", event.params.DeepCopy());
64 SendUpdate("media.onMediaEvent", &dict); 64 SendUpdate("media.onMediaEvent", &dict);
65 } 65 }
66 66
67 void MediaInternals::OnCaptureDevicesOpened( 67 void MediaInternals::OnCaptureDevicesOpened(
68 int render_process_id, 68 int render_process_id,
69 int render_view_id, 69 int render_view_id,
70 const content::MediaStreamDevices& devices) { 70 const content::MediaStreamDevices& devices) {
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
72 if (!media_stream_capture_indicator_.get())
73 media_stream_capture_indicator_ = new MediaStreamCaptureIndicator();
74 media_stream_capture_indicator_->CaptureDevicesOpened(render_process_id, 72 media_stream_capture_indicator_->CaptureDevicesOpened(render_process_id,
75 render_view_id, 73 render_view_id,
76 devices); 74 devices);
77 } 75 }
78 76
79 void MediaInternals::OnCaptureDevicesClosed( 77 void MediaInternals::OnCaptureDevicesClosed(
80 int render_process_id, 78 int render_process_id,
81 int render_view_id, 79 int render_view_id,
82 const content::MediaStreamDevices& devices) { 80 const content::MediaStreamDevices& devices) {
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 22 matching lines...) Expand all
106 void MediaInternals::RemoveObserver(MediaInternalsObserver* observer) { 104 void MediaInternals::RemoveObserver(MediaInternalsObserver* observer) {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
108 observers_.RemoveObserver(observer); 106 observers_.RemoveObserver(observer);
109 } 107 }
110 108
111 void MediaInternals::SendEverything() { 109 void MediaInternals::SendEverything() {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
113 SendUpdate("media.onReceiveEverything", &data_); 111 SendUpdate("media.onReceiveEverything", &data_);
114 } 112 }
115 113
116 MediaInternals::MediaInternals() {} 114 scoped_refptr<MediaStreamCaptureIndicator>
115 MediaInternals::GetMediaStreamCaptureIndicator() {
116 return media_stream_capture_indicator_.get();
117 }
118
119 MediaInternals::MediaInternals()
120 : media_stream_capture_indicator_(new MediaStreamCaptureIndicator()) {
121 }
117 122
118 void MediaInternals::UpdateAudioStream( 123 void MediaInternals::UpdateAudioStream(
119 void* host, int stream_id, const std::string& property, Value* value) { 124 void* host, int stream_id, const std::string& property, Value* value) {
120 std::string stream = base::StringPrintf("audio_streams.%p:%d", 125 std::string stream = base::StringPrintf("audio_streams.%p:%d",
121 host, stream_id); 126 host, stream_id);
122 UpdateItem("media.addAudioStream", stream, property, value); 127 UpdateItem("media.addAudioStream", stream, property, value);
123 } 128 }
124 129
125 void MediaInternals::DeleteItem(const std::string& item) { 130 void MediaInternals::DeleteItem(const std::string& item) {
126 data_.Remove(item, NULL); 131 data_.Remove(item, NULL);
(...skipping 16 matching lines...) Expand all
143 148
144 void MediaInternals::SendUpdate(const std::string& function, Value* value) { 149 void MediaInternals::SendUpdate(const std::string& function, Value* value) {
145 // Only bother serializing the update to JSON if someone is watching. 150 // Only bother serializing the update to JSON if someone is watching.
146 if (observers_.size()) { 151 if (observers_.size()) {
147 std::vector<const Value*> args; 152 std::vector<const Value*> args;
148 args.push_back(value); 153 args.push_back(value);
149 string16 update = content::WebUI::GetJavascriptCall(function, args); 154 string16 update = content::WebUI::GetJavascriptCall(function, args);
150 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update)); 155 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update));
151 } 156 }
152 } 157 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_internals.h ('k') | chrome/browser/media/media_stream_capture_indicator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698