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

Unified Diff: chrome/browser/ui/webui/media_internals_proxy.cc

Issue 7272036: Make MediaInternalsUI talk to MediaInternals. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Moving MediaInternalsProxy to its own file. Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/media_internals_proxy.cc
diff --git a/chrome/browser/ui/webui/media_internals_proxy.cc b/chrome/browser/ui/webui/media_internals_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..67aeed749a79c5210e9dc68d789acac8ee2fa545
--- /dev/null
+++ b/chrome/browser/ui/webui/media_internals_proxy.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/media_internals_proxy.h"
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/io_thread.h"
+#include "chrome/browser/media/media_internals.h"
+#include "chrome/browser/ui/webui/media_internals_ui.h"
+
+MediaInternalsProxy::MediaInternalsProxy() {
+ io_thread_ = g_browser_process->io_thread();
+};
scherkus (not reviewing) 2011/06/29 17:55:12 remove ;
Scott Franklin 2011/06/29 18:44:33 Done.
+
+void MediaInternalsProxy::SetUI(MediaInternalsUI* ui) {
+ ui_ = ui;
scherkus (not reviewing) 2011/06/29 17:55:12 since these are public methods add DCHECK for bein
Scott Franklin 2011/06/29 18:44:33 Done.
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(this,
+ &MediaInternalsProxy::ObserveMediaInternalsOnIOThread));
+};
scherkus (not reviewing) 2011/06/29 17:55:12 remove ;
Scott Franklin 2011/06/29 18:44:33 Done.
+
+void MediaInternalsProxy::RemoveUI() {
+ ui_ = NULL;
scherkus (not reviewing) 2011/06/29 17:55:12 ditto
Scott Franklin 2011/06/29 18:44:33 Done.
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(this,
+ &MediaInternalsProxy::StopObservingMediaInternalsOnIOThread));
+}
+
+void MediaInternalsProxy::GetEverything() {
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &MediaInternalsProxy::GetEverythingOnIOThread));
+}
+
+void MediaInternalsProxy::OnUpdate(const string16& update) {
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ NewRunnableMethod(this,
+ &MediaInternalsProxy::UpdateUIOnUIThread, update));
+}
+
+MediaInternalsProxy::~MediaInternalsProxy() {}
+
+void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() {
+ io_thread_->globals()->media.media_internals->AddUI(this);
+}
+
+void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() {
+ io_thread_->globals()->media.media_internals->RemoveUI(this);
+}
+
+void MediaInternalsProxy::GetEverythingOnIOThread() {
+ io_thread_->globals()->media.media_internals->SendEverything();
+}
+
+void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) {
+ // Don't forward updates to a destructed UI.
+ if (ui_)
+ ui_->OnUpdate(update);
+}

Powered by Google App Engine
This is Rietveld 408576698