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