| 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 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class ListValue; | 21 class ListValue; |
| 22 class Value; | 22 class Value; |
| 23 } | 23 } |
| 24 | 24 |
| 25 // This class is a proxy between MediaInternals (on the IO thread) and | 25 // This class is a proxy between MediaInternals (on the IO thread) and |
| 26 // MediaInternalsMessageHandler (on the UI thread). | 26 // MediaInternalsMessageHandler (on the UI thread). |
| 27 // It is ref_counted to ensure that it completes all pending Tasks on both | 27 // It is ref_counted to ensure that it completes all pending Tasks on both |
| 28 // threads before destruction. | 28 // threads before destruction. |
| 29 class MediaInternalsProxy | 29 class MediaInternalsProxy |
| 30 : public MediaInternalsObserver, | 30 : public MediaInternalsObserver, |
| 31 public base::RefCountedThreadSafe<MediaInternalsProxy, | 31 public base::RefCountedThreadSafe< |
| 32 BrowserThread::DeleteOnUIThread>, | 32 MediaInternalsProxy, |
| 33 content::BrowserThread::DeleteOnUIThread>, |
| 33 public ChromeNetLog::ThreadSafeObserverImpl, | 34 public ChromeNetLog::ThreadSafeObserverImpl, |
| 34 public content::NotificationObserver { | 35 public content::NotificationObserver { |
| 35 public: | 36 public: |
| 36 MediaInternalsProxy(); | 37 MediaInternalsProxy(); |
| 37 | 38 |
| 38 // content::NotificationObserver implementation. | 39 // content::NotificationObserver implementation. |
| 39 virtual void Observe(int type, | 40 virtual void Observe(int type, |
| 40 const content::NotificationSource& source, | 41 const content::NotificationSource& source, |
| 41 const content::NotificationDetails& details); | 42 const content::NotificationDetails& details); |
| 42 | 43 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 53 virtual void OnUpdate(const string16& update); | 54 virtual void OnUpdate(const string16& update); |
| 54 | 55 |
| 55 // ChromeNetLog::ThreadSafeObserver implementation. Callable from any thread: | 56 // ChromeNetLog::ThreadSafeObserver implementation. Callable from any thread: |
| 56 virtual void OnAddEntry(net::NetLog::EventType type, | 57 virtual void OnAddEntry(net::NetLog::EventType type, |
| 57 const base::TimeTicks& time, | 58 const base::TimeTicks& time, |
| 58 const net::NetLog::Source& source, | 59 const net::NetLog::Source& source, |
| 59 net::NetLog::EventPhase phase, | 60 net::NetLog::EventPhase phase, |
| 60 net::NetLog::EventParameters* params) OVERRIDE; | 61 net::NetLog::EventParameters* params) OVERRIDE; |
| 61 | 62 |
| 62 private: | 63 private: |
| 63 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 64 friend struct content::BrowserThread::DeleteOnThread< |
| 65 content::BrowserThread::UI>; |
| 64 friend class DeleteTask<MediaInternalsProxy>; | 66 friend class DeleteTask<MediaInternalsProxy>; |
| 65 virtual ~MediaInternalsProxy(); | 67 virtual ~MediaInternalsProxy(); |
| 66 | 68 |
| 67 // Build a dictionary mapping constant names to values. | 69 // Build a dictionary mapping constant names to values. |
| 68 base::Value* GetConstants(); | 70 base::Value* GetConstants(); |
| 69 | 71 |
| 70 void ObserveMediaInternalsOnIOThread(); | 72 void ObserveMediaInternalsOnIOThread(); |
| 71 void StopObservingMediaInternalsOnIOThread(); | 73 void StopObservingMediaInternalsOnIOThread(); |
| 72 void GetEverythingOnIOThread(); | 74 void GetEverythingOnIOThread(); |
| 73 void UpdateUIOnUIThread(const string16& update); | 75 void UpdateUIOnUIThread(const string16& update); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 | 86 |
| 85 MediaInternalsMessageHandler* handler_; | 87 MediaInternalsMessageHandler* handler_; |
| 86 IOThread* io_thread_; | 88 IOThread* io_thread_; |
| 87 scoped_ptr<base::ListValue> pending_net_updates_; | 89 scoped_ptr<base::ListValue> pending_net_updates_; |
| 88 content::NotificationRegistrar registrar_; | 90 content::NotificationRegistrar registrar_; |
| 89 | 91 |
| 90 DISALLOW_COPY_AND_ASSIGN(MediaInternalsProxy); | 92 DISALLOW_COPY_AND_ASSIGN(MediaInternalsProxy); |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ | 95 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_MEDIA_INTERNALS_PROXY_H_ |
| OLD | NEW |