| Index: content/public/browser/remote_frame_interface.h
|
| diff --git a/content/public/browser/remote_frame_interface.h b/content/public/browser/remote_frame_interface.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2b39694819069a82fe52eb3184dd6f354362603c
|
| --- /dev/null
|
| +++ b/content/public/browser/remote_frame_interface.h
|
| @@ -0,0 +1,47 @@
|
| +// Copyright 2016 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 CONTENT_PUBLIC_BROWSER_REMOTE_FRAME_INTERFACE_H_
|
| +#define CONTENT_PUBLIC_BROWSER_REMOTE_FRAME_INTERFACE_H_
|
| +
|
| +#include <unordered_map>
|
| +#include <utility>
|
| +
|
| +#include "base/macros.h"
|
| +#include "content/public/browser/render_frame_host.h"
|
| +#include "mojo/public/cpp/bindings/associated_interface_ptr.h"
|
| +
|
| +namespace content {
|
| +
|
| +// A helper class which caches associated interface proxies per RenderFrameHost.
|
| +template <typename Interface>
|
| +class RemoteFrameInterface {
|
| + public:
|
| + RemoteFrameInterface() = default;
|
| + ~RemoteFrameInterface() = default;
|
| +
|
| + Interface* ForFrame(RenderFrameHost* render_frame_host) {
|
| + auto it = frame_proxies_.find(render_frame_host);
|
| + if (it == frame_proxies_.end()) {
|
| + ProxyType proxy;
|
| + render_frame_host->GetRemoteRoutedInterface(&proxy);
|
| + auto result = frame_proxies_.insert(
|
| + std::make_pair(render_frame_host, std::move(proxy)));
|
| + DCHECK(result.second);
|
| + it = result.first;
|
| + }
|
| + return it->second.get();
|
| + }
|
| +
|
| + private:
|
| + using ProxyType = mojo::AssociatedInterfacePtr<Interface>;
|
| +
|
| + std::unordered_map<RenderFrameHost*, ProxyType> frame_proxies_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RemoteFrameInterface);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_PUBLIC_BROWSER_REMOTE_FRAME_INTERFACE_H_
|
|
|