| Index: chrome/browser/ui/webui/media/webrtc_internals_proxy.h
|
| diff --git a/chrome/browser/ui/webui/media/webrtc_internals_proxy.h b/chrome/browser/ui/webui/media/webrtc_internals_proxy.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..eb96ab4805d7346edd3171938b92ecf79b600c80
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/webui/media/webrtc_internals_proxy.h
|
| @@ -0,0 +1,53 @@
|
| +// Copyright (c) 2013 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_WEBRTC_INTERNALS_PROXY_H_
|
| +#define CHROME_BROWSER_UI_WEBUI_MEDIA_WEBRTC_INTERNALS_PROXY_H_
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/string16.h"
|
| +#include "chrome/browser/media/webrtc_internals_ui_observer.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +
|
| +class WebRTCInternalsMessageHandler;
|
| +
|
| +// This class is a proxy between WebRTCInternals on the IO thread and
|
| +// WebRTCInternalsMessageHandler on the UI thread.
|
| +// It is ref_counted to ensure that it completes all pending tasks on both
|
| +// threads before destruction.
|
| +class WebRTCInternalsProxy
|
| + : public media::WebRTCInternalsUIObserver,
|
| + public base::RefCountedThreadSafe<
|
| + WebRTCInternalsProxy,
|
| + content::BrowserThread::DeleteOnUIThread> {
|
| + public:
|
| + WebRTCInternalsProxy();
|
| +
|
| + // WebRTCInternalsUIObserver override
|
| + virtual void OnUpdate(const std::string& command,
|
| + const base::Value* args) OVERRIDE;
|
| +
|
| + // Attach a handler and start receiving callbacks from WebRTCInternals.
|
| + void Attach(WebRTCInternalsMessageHandler* handler);
|
| +
|
| + // Detach the handler and stop receiving callbacks.
|
| + void Detach();
|
| +
|
| + private:
|
| + friend struct content::BrowserThread::DeleteOnThread<
|
| + content::BrowserThread::UI>;
|
| + friend class base::DeleteHelper<WebRTCInternalsProxy>;
|
| +
|
| + virtual ~WebRTCInternalsProxy();
|
| +
|
| + void ObserveWebRTCInternalsOnIOThread();
|
| + void StopObservingWebRTCInternalsOnIOThread();
|
| + void UpdateOnUIThread(const string16& update);
|
| +
|
| + WebRTCInternalsMessageHandler* handler_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebRTCInternalsProxy);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_UI_WEBUI_MEDIA_WEBRTC_INTERNALS_PROXY_H_
|
|
|