OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_WEBRTC_INTERNALS_PROXY_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_WEBRTC_INTERNALS_PROXY_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/string16.h" |
| 10 #include "chrome/browser/media/webrtc_internals_ui_observer.h" |
| 11 #include "content/public/browser/browser_thread.h" |
| 12 |
| 13 class WebRTCInternalsMessageHandler; |
| 14 |
| 15 // This class is a proxy between WebRTCInternals on the IO thread and |
| 16 // WebRTCInternalsMessageHandler on the UI thread. |
| 17 // It is ref_counted to ensure that it completes all pending tasks on both |
| 18 // threads before destruction. |
| 19 class WebRTCInternalsProxy |
| 20 : public media::WebRTCInternalsUIObserver, |
| 21 public base::RefCountedThreadSafe< |
| 22 WebRTCInternalsProxy, |
| 23 content::BrowserThread::DeleteOnUIThread> { |
| 24 public: |
| 25 WebRTCInternalsProxy(); |
| 26 |
| 27 // WebRTCInternalsUIObserver override. |
| 28 virtual void OnUpdate(const std::string& command, |
| 29 const base::Value* args) OVERRIDE; |
| 30 |
| 31 // Attach a handler and start receiving callbacks from WebRTCInternals. |
| 32 void Attach(WebRTCInternalsMessageHandler* handler); |
| 33 |
| 34 // Detach the handler and stop receiving callbacks. |
| 35 void Detach(); |
| 36 |
| 37 private: |
| 38 friend struct content::BrowserThread::DeleteOnThread< |
| 39 content::BrowserThread::UI>; |
| 40 friend class base::DeleteHelper<WebRTCInternalsProxy>; |
| 41 |
| 42 virtual ~WebRTCInternalsProxy(); |
| 43 |
| 44 void ObserveWebRTCInternalsOnIOThread(); |
| 45 void StopObservingWebRTCInternalsOnIOThread(); |
| 46 void UpdateOnUIThread(const string16& update); |
| 47 |
| 48 WebRTCInternalsMessageHandler* handler_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(WebRTCInternalsProxy); |
| 51 }; |
| 52 |
| 53 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_WEBRTC_INTERNALS_PROXY_H_ |
OLD | NEW |