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

Unified Diff: chrome/browser/ui/webui/media_internals/media_internals_proxy.h

Issue 7272036: Make MediaInternalsUI talk to MediaInternals. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Splitting it all up. 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/media_internals_proxy.h
diff --git a/chrome/browser/ui/webui/media_internals/media_internals_proxy.h b/chrome/browser/ui/webui/media_internals/media_internals_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..b35d9c3fa4acc0695df6739449e561f12e0b6d6a
--- /dev/null
+++ b/chrome/browser/ui/webui/media_internals/media_internals_proxy.h
@@ -0,0 +1,53 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_INTERNALS_MEDIA_INTERNALS_PROXY_H_
+#define CHROME_BROWSER_UI_WEBUI_MEDIA_INTERNALS_MEDIA_INTERNALS_PROXY_H_
+#pragma once
+
+#include "base/string16.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/media/media_internals_observer.h"
+
+class IOThread;
+class MediaInternalsMessageHandler;
+
+// This class is a proxy between MediaInternals (on the IO thread) and
+// MediaInternalsMessageHandler (on the UI thread).
+// It is ref_counted to ensure that it completes all pending Tasks on both
+// threads before destruction.
+class MediaInternalsProxy
+ : public MediaInternalsObserver,
+ public base::RefCountedThreadSafe<MediaInternalsProxy> {
+ public:
+ MediaInternalsProxy();
+
+ // Register a Handler and start receiving callbacks from MediaInternals.
+ void Attach(MediaInternalsMessageHandler* handler);
+
+ // Unregister the same and stop receiving callbacks.
+ void Detach();
+
+ // Have MediaInternals send all the data it has.
+ void GetEverything();
+
+ // MediaInternalsObserver implementation. Called on the IO thread.
+ virtual void OnUpdate(const string16& update);
+
+ private:
+ friend class base::RefCountedThreadSafe<MediaInternalsProxy>;
+ virtual ~MediaInternalsProxy();
+
+ void ObserveMediaInternalsOnIOThread();
+ void StopObservingMediaInternalsOnIOThread();
+ void GetEverythingOnIOThread();
+ void UpdateUIOnUIThread(const string16& update);
+
+ MediaInternalsMessageHandler* handler_;
+ IOThread* io_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaInternalsProxy);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_MEDIA_INTERNALS_MEDIA_INTERNALS_PROXY_H_

Powered by Google App Engine
This is Rietveld 408576698