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

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

Issue 7480032: Plumb media data from renderers up to MediaInternals in the browser process. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebasing onto http://codereview.chromium.org/7491048 prior to (hopefully) relanding. Created 9 years, 4 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "content/browser/browser_thread.h" 11 #include "content/browser/browser_thread.h"
12 #include "content/browser/webui/web_ui.h" 12 #include "content/browser/webui/web_ui.h"
13 #include "media/base/media_log_event.h"
13 14
14 // The names of the javascript functions to call with updates. 15 // The names of the javascript functions to call with updates.
15 static const char kDeleteItemFunction[] = "media.onItemDeleted"; 16 static const char kDeleteItemFunction[] = "media.onItemDeleted";
16 static const char kAudioUpdateFunction[] = "media.addAudioStream"; 17 static const char kAudioUpdateFunction[] = "media.addAudioStream";
17 static const char kSendEverythingFunction[] = "media.onReceiveEverything"; 18 static const char kSendEverythingFunction[] = "media.onReceiveEverything";
18 19
19 MediaInternals::~MediaInternals() {} 20 MediaInternals::~MediaInternals() {}
20 21
21 void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) { 22 void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) {
22 DCHECK(CalledOnValidThread()); 23 DCHECK(CalledOnValidThread());
(...skipping 16 matching lines...) Expand all
39 "status", Value::CreateStringValue(status)); 40 "status", Value::CreateStringValue(status));
40 } 41 }
41 42
42 void MediaInternals::OnSetAudioStreamVolume( 43 void MediaInternals::OnSetAudioStreamVolume(
43 void* host, int stream_id, double volume) { 44 void* host, int stream_id, double volume) {
44 DCHECK(CalledOnValidThread()); 45 DCHECK(CalledOnValidThread());
45 UpdateAudioStream(host, stream_id, 46 UpdateAudioStream(host, stream_id,
46 "volume", Value::CreateDoubleValue(volume)); 47 "volume", Value::CreateDoubleValue(volume));
47 } 48 }
48 49
50 void MediaInternals::OnMediaEvent(
51 int render_process_id, const media::MediaLogEvent& event) {
52 DCHECK(CalledOnValidThread());
53 // TODO(scottfr): Handle |event|. Record status information in data_ and pass
54 // |event| along to observers.
55 }
56
49 void MediaInternals::AddObserver(MediaInternalsObserver* observer) { 57 void MediaInternals::AddObserver(MediaInternalsObserver* observer) {
50 DCHECK(CalledOnValidThread()); 58 DCHECK(CalledOnValidThread());
51 observers_.AddObserver(observer); 59 observers_.AddObserver(observer);
52 } 60 }
53 61
54 void MediaInternals::RemoveObserver(MediaInternalsObserver* observer) { 62 void MediaInternals::RemoveObserver(MediaInternalsObserver* observer) {
55 DCHECK(CalledOnValidThread()); 63 DCHECK(CalledOnValidThread());
56 observers_.RemoveObserver(observer); 64 observers_.RemoveObserver(observer);
57 } 65 }
58 66
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 99
92 void MediaInternals::SendUpdate(const std::string& function, Value* value) { 100 void MediaInternals::SendUpdate(const std::string& function, Value* value) {
93 // Only bother serializing the update to JSON if someone is watching. 101 // Only bother serializing the update to JSON if someone is watching.
94 if (observers_.size()) { 102 if (observers_.size()) {
95 std::vector<const Value*> args; 103 std::vector<const Value*> args;
96 args.push_back(value); 104 args.push_back(value);
97 string16 update = WebUI::GetJavascriptCall(function, args); 105 string16 update = WebUI::GetJavascriptCall(function, args);
98 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update)); 106 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update));
99 } 107 }
100 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698