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

Side by Side Diff: content/browser/media/media_internals_proxy.h

Issue 12153002: Move chrome://media-internals to content. This allows us to hide implementation details from the pu… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_PROXY_H_
6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ 6 #define CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_PROXY_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/sequenced_task_runner_helpers.h" 9 #include "base/sequenced_task_runner_helpers.h"
10 #include "base/string16.h" 10 #include "content/browser/media/media_internals.h"
11 #include "chrome/browser/media/media_internals_observer.h"
12 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
15 #include "net/base/net_log.h" 14 #include "net/base/net_log.h"
16 15
17 class IOThread;
18 class MediaInternalsMessageHandler;
19
20 namespace base { 16 namespace base {
21 class ListValue; 17 class ListValue;
22 class Value; 18 class Value;
23 } 19 }
24 20
21 namespace content {
22 class MediaInternalsMessageHandler;
23
25 // This class is a proxy between MediaInternals (on the IO thread) and 24 // This class is a proxy between MediaInternals (on the IO thread) and
26 // MediaInternalsMessageHandler (on the UI thread). 25 // MediaInternalsMessageHandler (on the UI thread).
27 // It is ref_counted to ensure that it completes all pending Tasks on both 26 // It is ref_counted to ensure that it completes all pending Tasks on both
28 // threads before destruction. 27 // threads before destruction.
29 class MediaInternalsProxy 28 class MediaInternalsProxy
30 : public MediaInternalsObserver, 29 : public base::RefCountedThreadSafe<
31 public base::RefCountedThreadSafe<
32 MediaInternalsProxy, 30 MediaInternalsProxy,
33 content::BrowserThread::DeleteOnUIThread>, 31 BrowserThread::DeleteOnUIThread>,
34 public net::NetLog::ThreadSafeObserver, 32 public net::NetLog::ThreadSafeObserver,
35 public content::NotificationObserver { 33 public NotificationObserver {
36 public: 34 public:
37 MediaInternalsProxy(); 35 MediaInternalsProxy();
38 36
39 // content::NotificationObserver implementation. 37 // NotificationObserver implementation.
40 virtual void Observe(int type, 38 virtual void Observe(int type,
41 const content::NotificationSource& source, 39 const NotificationSource& source,
42 const content::NotificationDetails& details) OVERRIDE; 40 const NotificationDetails& details) OVERRIDE;
43 41
44 // Register a Handler and start receiving callbacks from MediaInternals. 42 // Register a Handler and start receiving callbacks from MediaInternals.
45 void Attach(MediaInternalsMessageHandler* handler); 43 void Attach(MediaInternalsMessageHandler* handler);
46 44
47 // Unregister the same and stop receiving callbacks. 45 // Unregister the same and stop receiving callbacks.
48 void Detach(); 46 void Detach();
49 47
50 // Have MediaInternals send all the data it has. 48 // Have MediaInternals send all the data it has.
51 void GetEverything(); 49 void GetEverything();
52 50
53 // MediaInternalsObserver implementation. Called on the IO thread. 51 // MediaInternals callback. Called on the IO thread.
54 virtual void OnUpdate(const string16& update) OVERRIDE; 52 void OnUpdate(const string16& update);
55 53
56 // net::NetLog::ThreadSafeObserver implementation. Callable from any thread: 54 // net::NetLog::ThreadSafeObserver implementation. Callable from any thread:
57 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; 55 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE;
58 56
59 private: 57 private:
60 friend struct content::BrowserThread::DeleteOnThread< 58 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
61 content::BrowserThread::UI>;
62 friend class base::DeleteHelper<MediaInternalsProxy>; 59 friend class base::DeleteHelper<MediaInternalsProxy>;
63 virtual ~MediaInternalsProxy(); 60 virtual ~MediaInternalsProxy();
64 61
65 // Build a dictionary mapping constant names to values. 62 // Build a dictionary mapping constant names to values.
66 base::Value* GetConstants(); 63 base::Value* GetConstants();
67 64
68 void ObserveMediaInternalsOnIOThread(); 65 void ObserveMediaInternalsOnIOThread();
69 void StopObservingMediaInternalsOnIOThread(); 66 void StopObservingMediaInternalsOnIOThread();
70 void GetEverythingOnIOThread(); 67 void GetEverythingOnIOThread();
71 void UpdateUIOnUIThread(const string16& update); 68 void UpdateUIOnUIThread(const string16& update);
72 69
73 // Put |entry| on a list of events to be sent to the page. 70 // Put |entry| on a list of events to be sent to the page.
74 void AddNetEventOnUIThread(base::Value* entry); 71 void AddNetEventOnUIThread(base::Value* entry);
75 72
76 // Send all pending events to the page. 73 // Send all pending events to the page.
77 void SendNetEventsOnUIThread(); 74 void SendNetEventsOnUIThread();
78 75
79 // Call a JavaScript function on the page. Takes ownership of |args|. 76 // Call a JavaScript function on the page. Takes ownership of |args|.
80 void CallJavaScriptFunctionOnUIThread(const std::string& function, 77 void CallJavaScriptFunctionOnUIThread(const std::string& function,
81 base::Value* args); 78 base::Value* args);
82 79
83 MediaInternalsMessageHandler* handler_; 80 MediaInternalsMessageHandler* handler_;
84 IOThread* io_thread_;
85 scoped_ptr<base::ListValue> pending_net_updates_; 81 scoped_ptr<base::ListValue> pending_net_updates_;
86 content::NotificationRegistrar registrar_; 82 NotificationRegistrar registrar_;
83 MediaInternals::UpdateCallback update_callback_;
87 84
88 DISALLOW_COPY_AND_ASSIGN(MediaInternalsProxy); 85 DISALLOW_COPY_AND_ASSIGN(MediaInternalsProxy);
89 }; 86 };
90 87
91 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ 88 } // namespace content
89
90 #endif // CONTENT_BROWSER_MEDIA_MEDIA_INTERNALS_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698