Commit ceff908a authored by sammc's avatar sammc Committed by Commit bot

Remove mojo::InterfaceImpl from extensions.

BUG=489751

Review URL: https://codereview.chromium.org/1148703002

Cr-Commit-Position: refs/heads/master@{#330699}
parent a6faceeb
......@@ -49,12 +49,15 @@ mojo::Map<mojo::String, mojo::String> CreateResponseHeadersMap(
void MimeHandlerServiceImpl::Create(
base::WeakPtr<StreamContainer> stream_container,
mojo::InterfaceRequest<mime_handler::MimeHandlerService> request) {
mojo::BindToRequest(new MimeHandlerServiceImpl(stream_container), &request);
new MimeHandlerServiceImpl(stream_container, request.Pass());
}
MimeHandlerServiceImpl::MimeHandlerServiceImpl(
base::WeakPtr<StreamContainer> stream_container)
: stream_(stream_container), weak_factory_(this) {
base::WeakPtr<StreamContainer> stream_container,
mojo::InterfaceRequest<mime_handler::MimeHandlerService> request)
: stream_(stream_container),
binding_(this, request.Pass()),
weak_factory_(this) {
}
MimeHandlerServiceImpl::~MimeHandlerServiceImpl() {
......
......@@ -7,13 +7,13 @@
#include "base/memory/weak_ptr.h"
#include "extensions/common/api/mime_handler.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
namespace extensions {
class StreamContainer;
class MimeHandlerServiceImplTest;
class MimeHandlerServiceImpl
: public mojo::InterfaceImpl<mime_handler::MimeHandlerService> {
class MimeHandlerServiceImpl : public mime_handler::MimeHandlerService {
public:
static void Create(
base::WeakPtr<StreamContainer> stream_container,
......@@ -22,8 +22,9 @@ class MimeHandlerServiceImpl
private:
friend class MimeHandlerServiceImplTest;
explicit MimeHandlerServiceImpl(
base::WeakPtr<StreamContainer> stream_container);
MimeHandlerServiceImpl(
base::WeakPtr<StreamContainer> stream_container,
mojo::InterfaceRequest<mime_handler::MimeHandlerService> request);
~MimeHandlerServiceImpl() override;
// mime_handler::MimeHandlerService overrides.
......@@ -37,6 +38,8 @@ class MimeHandlerServiceImpl
// A handle to the stream being handled by the MimeHandlerViewGuest.
base::WeakPtr<StreamContainer> stream_;
mojo::StrongBinding<mime_handler::MimeHandlerService> binding_;
base::WeakPtrFactory<MimeHandlerServiceImpl> weak_factory_;
};
......
......@@ -42,7 +42,8 @@ class MimeHandlerServiceImplTest : public testing::Test {
stream_info->original_url = GURL("test://extensions_unittests");
stream_container_.reset(
new StreamContainer(stream_info.Pass(), 1, true, GURL(), ""));
service_.reset(new MimeHandlerServiceImpl(stream_container_->GetWeakPtr()));
service_.reset(new MimeHandlerServiceImpl(stream_container_->GetWeakPtr(),
mojo::GetProxy(&service_ptr_)));
}
void TearDown() override {
service_.reset();
......@@ -54,7 +55,9 @@ class MimeHandlerServiceImplTest : public testing::Test {
stream_info_ = stream_info.Pass();
}
base::MessageLoop message_loop_;
scoped_ptr<StreamContainer> stream_container_;
mime_handler::MimeHandlerServicePtr service_ptr_;
scoped_ptr<mime_handler::MimeHandlerService> service_;
bool abort_called_ = false;
mime_handler::StreamInfoPtr stream_info_;
......
......@@ -12,12 +12,13 @@ namespace extensions {
void KeepAliveImpl::Create(content::BrowserContext* context,
const Extension* extension,
mojo::InterfaceRequest<KeepAlive> request) {
mojo::BindToRequest(new KeepAliveImpl(context, extension), &request);
new KeepAliveImpl(context, extension, request.Pass());
}
KeepAliveImpl::KeepAliveImpl(content::BrowserContext* context,
const Extension* extension)
: context_(context), extension_(extension) {
const Extension* extension,
mojo::InterfaceRequest<KeepAlive> request)
: context_(context), extension_(extension), binding_(this, request.Pass()) {
ProcessManager::Get(context_)->IncrementLazyKeepaliveCount(extension_);
}
......
......@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "extensions/common/mojo/keep_alive.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
namespace content {
class BrowserContext;
......@@ -18,7 +19,7 @@ class Extension;
// An RAII mojo service implementation for extension keep alives. This adds a
// keep alive on construction and removes it on destruction.
class KeepAliveImpl : public mojo::InterfaceImpl<KeepAlive> {
class KeepAliveImpl : public KeepAlive {
public:
// Create a keep alive for |extension| running in |context| and connect it to
// |request|. When the requester closes its pipe, the keep alive ends.
......@@ -27,11 +28,14 @@ class KeepAliveImpl : public mojo::InterfaceImpl<KeepAlive> {
mojo::InterfaceRequest<KeepAlive> request);
private:
KeepAliveImpl(content::BrowserContext* context, const Extension* extension);
KeepAliveImpl(content::BrowserContext* context,
const Extension* extension,
mojo::InterfaceRequest<KeepAlive> request);
~KeepAliveImpl() override;
content::BrowserContext* context_;
const Extension* extension_;
mojo::StrongBinding<KeepAlive> binding_;
DISALLOW_COPY_AND_ASSIGN(KeepAliveImpl);
};
......
......@@ -5,7 +5,7 @@
#include "extensions/common/mojo/keep_alive.mojom.h"
#include "extensions/renderer/api_test_base.h"
#include "grit/extensions_renderer_resources.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
// A test launcher for tests for the stash client defined in
// extensions/test/data/keep_alive_client_unittest.js.
......@@ -15,22 +15,24 @@ namespace {
// A KeepAlive implementation that calls provided callbacks on creation and
// destruction.
class TestKeepAlive : public mojo::InterfaceImpl<KeepAlive> {
class TestKeepAlive : public KeepAlive {
public:
explicit TestKeepAlive(const base::Closure& on_destruction)
: on_destruction_(on_destruction) {}
TestKeepAlive(const base::Closure& on_destruction,
mojo::InterfaceRequest<KeepAlive> keep_alive)
: on_destruction_(on_destruction), binding_(this, keep_alive.Pass()) {}
~TestKeepAlive() override { on_destruction_.Run(); }
static void Create(const base::Closure& on_creation,
const base::Closure& on_destruction,
mojo::InterfaceRequest<KeepAlive> keep_alive) {
mojo::BindToRequest(new TestKeepAlive(on_destruction), &keep_alive);
new TestKeepAlive(on_destruction, keep_alive.Pass());
on_creation.Run();
}
private:
const base::Closure on_destruction_;
mojo::StrongBinding<KeepAlive> binding_;
};
} // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment