| OLD | NEW |
| 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 | 13 |
| 14 // The names of the javascript functions to call with updates. | 14 // The names of the javascript functions to call with updates. |
| 15 static const char kDeleteItemFunction[] = "onItemDeleted"; | 15 static const char kDeleteItemFunction[] = "media.onItemDeleted"; |
| 16 static const char kAudioUpdateFunction[] = "onAudioUpdate"; | 16 static const char kAudioUpdateFunction[] = "media.addAudioStream"; |
| 17 static const char kSendEverythingFunction[] = "onReceiveEverything"; | 17 static const char kSendEverythingFunction[] = "media.onReceiveEverything"; |
| 18 | 18 |
| 19 MediaInternals::~MediaInternals() {} | 19 MediaInternals::~MediaInternals() {} |
| 20 | 20 |
| 21 void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) { | 21 void MediaInternals::OnDeleteAudioStream(void* host, int stream_id) { |
| 22 DCHECK(CalledOnValidThread()); | 22 DCHECK(CalledOnValidThread()); |
| 23 std::string stream = base::StringPrintf("audio_streams.%p:%d", | 23 std::string stream = base::StringPrintf("audio_streams.%p:%d", |
| 24 host, stream_id); | 24 host, stream_id); |
| 25 DeleteItem(stream); | 25 DeleteItem(stream); |
| 26 } | 26 } |
| 27 | 27 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 void MediaInternals::SendUpdate(const std::string& function, Value* value) { | 92 void MediaInternals::SendUpdate(const std::string& function, Value* value) { |
| 93 // Only bother serializing the update to JSON if someone is watching. | 93 // Only bother serializing the update to JSON if someone is watching. |
| 94 if (observers_.size()) { | 94 if (observers_.size()) { |
| 95 std::vector<const Value*> args; | 95 std::vector<const Value*> args; |
| 96 args.push_back(value); | 96 args.push_back(value); |
| 97 string16 update = WebUI::GetJavascriptCall(function, args); | 97 string16 update = WebUI::GetJavascriptCall(function, args); |
| 98 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update)); | 98 FOR_EACH_OBSERVER(MediaInternalsObserver, observers_, OnUpdate(update)); |
| 99 } | 99 } |
| 100 } | 100 } |
| OLD | NEW |