Index: mojo/application/content_handler.cc |
diff --git a/mojo/application/content_handler.cc b/mojo/application/content_handler.cc |
index e9fb0dab8e32a888ad4eab38015e0b1bb1ea889d..5c02af48f6160fed645d3f6201afa231282d99ce 100644 |
--- a/mojo/application/content_handler.cc |
+++ b/mojo/application/content_handler.cc |
@@ -13,9 +13,7 @@ |
#include "mojo/public/cpp/application/application_connection.h" |
#include "mojo/public/cpp/application/application_delegate.h" |
#include "mojo/public/cpp/application/application_impl.h" |
-#include "mojo/public/cpp/application/interface_factory_impl.h" |
#include "mojo/public/cpp/bindings/interface_impl.h" |
-#include "mojo/services/public/interfaces/content_handler/content_handler.mojom.h" |
namespace mojo { |
@@ -26,20 +24,21 @@ class ApplicationThread : public base::PlatformThread::Delegate { |
ApplicationThread( |
scoped_refptr<base::MessageLoopProxy> handler_thread, |
const base::Callback<void(ApplicationThread*)>& termination_callback, |
- mojo::ContentHandlerDelegate* handler_delegate, |
+ ContentHandlerFactory::Delegate* delegate, |
ShellPtr shell, |
URLResponsePtr response) |
: handler_thread_(handler_thread), |
termination_callback_(termination_callback), |
- handler_delegate_(handler_delegate), |
+ delegate_(delegate), |
shell_(shell.Pass()), |
response_(response.Pass()) {} |
private: |
void ThreadMain() override { |
base::MessageLoop loop(common::MessagePumpMojo::Create()); |
- application_ = |
- handler_delegate_->CreateApplication(shell_.Pass(), response_.Pass()); |
+ application_.reset( |
+ new ApplicationImpl(delegate_->CreateApplication(response_.Pass()), |
+ shell_.PassMessagePipe())); |
loop.Run(); |
handler_thread_->PostTask(FROM_HERE, |
base::Bind(termination_callback_, this)); |
@@ -47,10 +46,9 @@ class ApplicationThread : public base::PlatformThread::Delegate { |
scoped_refptr<base::MessageLoopProxy> handler_thread_; |
base::Callback<void(ApplicationThread*)> termination_callback_; |
- mojo::ContentHandlerDelegate* handler_delegate_; |
+ ContentHandlerFactory::Delegate* delegate_; |
ShellPtr shell_; |
URLResponsePtr response_; |
- scoped_ptr<ApplicationDelegate> application_delegate_; |
scoped_ptr<mojo::InterfaceImpl<mojo::Application>> application_; |
DISALLOW_COPY_AND_ASSIGN(ApplicationThread); |
@@ -58,7 +56,7 @@ class ApplicationThread : public base::PlatformThread::Delegate { |
class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { |
public: |
- explicit ContentHandlerImpl(mojo::ContentHandlerDelegate* delegate) |
+ explicit ContentHandlerImpl(ContentHandlerFactory::Delegate* delegate) |
: delegate_(delegate) {} |
~ContentHandlerImpl() { |
for (auto thread : active_threads_) { |
@@ -94,51 +92,25 @@ class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { |
// quitting. |
} |
- mojo::ContentHandlerDelegate* delegate_; |
+ ContentHandlerFactory::Delegate* delegate_; |
std::map<ApplicationThread*, base::PlatformThreadHandle> active_threads_; |
DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); |
}; |
-class ContentHandlerApp : public ApplicationDelegate { |
- public: |
- explicit ContentHandlerApp(scoped_ptr<ContentHandlerDelegate> delegate) |
- : delegate_(delegate.Pass()), content_handler_factory_(delegate_.get()) {} |
- |
- private: |
- // Overridden from ApplicationDelegate: |
- virtual void Initialize(ApplicationImpl* app) override { |
- delegate_->Initialize(app); |
- } |
- |
- virtual bool ConfigureIncomingConnection( |
- ApplicationConnection* connection) override { |
- connection->AddService(&content_handler_factory_); |
- return delegate_->ConfigureIncomingConnection(connection); |
- } |
- |
- virtual bool ConfigureOutgoingConnection( |
- ApplicationConnection* connection) override { |
- return delegate_->ConfigureOutgoingConnection(connection); |
- } |
- |
- scoped_ptr<ContentHandlerDelegate> delegate_; |
- InterfaceFactoryImplWithContext<ContentHandlerImpl, |
- mojo::ContentHandlerDelegate> |
- content_handler_factory_; |
+} // namespace |
- DISALLOW_COPY_AND_ASSIGN(ContentHandlerApp); |
-}; |
+ContentHandlerFactory::ContentHandlerFactory( |
+ ContentHandlerFactory::Delegate* delegate) |
+ : delegate_(delegate) { |
+} |
-} // namespace |
+ContentHandlerFactory::~ContentHandlerFactory() { |
+} |
-// static |
-MojoResult ContentHandlerRunner::Run( |
- MojoHandle shell_handle, |
- scoped_ptr<mojo::ContentHandlerDelegate> delegate) { |
- mojo::ApplicationRunnerChromium runner( |
- new ContentHandlerApp(delegate.Pass())); |
- return runner.Run(shell_handle); |
+void ContentHandlerFactory::Create(ApplicationConnection* connection, |
+ InterfaceRequest<ContentHandler> request) { |
+ BindToRequest(new ContentHandlerImpl(delegate_), &request); |
} |
} // namespace mojo |