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

Side by Side Diff: chrome/browser/ui/webui/media_internals/media_internals_proxy.cc

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, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/media_internals/media_internals_proxy.h"
6
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/io_thread.h"
9 #include "chrome/browser/media/media_internals.h"
10 #include "chrome/browser/ui/webui/media_internals/media_internals_handler.h"
11
12 MediaInternalsProxy::MediaInternalsProxy() {
13 io_thread_ = g_browser_process->io_thread();
14 }
15
16 void MediaInternalsProxy::Attach(MediaInternalsMessageHandler* handler) {
17 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
18 handler_ = handler;
19 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
20 NewRunnableMethod(this,
21 &MediaInternalsProxy::ObserveMediaInternalsOnIOThread));
22 }
23
24 void MediaInternalsProxy::Detach() {
25 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
26 handler_ = NULL;
27 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
28 NewRunnableMethod(this,
29 &MediaInternalsProxy::StopObservingMediaInternalsOnIOThread));
30 }
31
32 void MediaInternalsProxy::GetEverything() {
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
34 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
35 NewRunnableMethod(this, &MediaInternalsProxy::GetEverythingOnIOThread));
36 }
37
38 void MediaInternalsProxy::OnUpdate(const string16& update) {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
40 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
41 NewRunnableMethod(this,
42 &MediaInternalsProxy::UpdateUIOnUIThread, update));
43 }
44
45 MediaInternalsProxy::~MediaInternalsProxy() {}
46
47 void MediaInternalsProxy::ObserveMediaInternalsOnIOThread() {
48 io_thread_->globals()->media.media_internals->AddUI(this);
49 }
50
51 void MediaInternalsProxy::StopObservingMediaInternalsOnIOThread() {
52 io_thread_->globals()->media.media_internals->RemoveUI(this);
53 }
54
55 void MediaInternalsProxy::GetEverythingOnIOThread() {
56 io_thread_->globals()->media.media_internals->SendEverything();
57 }
58
59 void MediaInternalsProxy::UpdateUIOnUIThread(const string16& update) {
60 // Don't forward updates to a destructed UI.
61 if (handler_)
62 handler_->OnUpdate(update);
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698