Index: mojo/services/html_viewer/html_viewer.cc |
diff --git a/mojo/services/html_viewer/html_viewer.cc b/mojo/services/html_viewer/html_viewer.cc |
index e8b5c76314bbf01afa43a1b6b037f18a495b866b..2a8e766679b01c982763bd01230c41718c61f38a 100644 |
--- a/mojo/services/html_viewer/html_viewer.cc |
+++ b/mojo/services/html_viewer/html_viewer.cc |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
#include "base/message_loop/message_loop.h" |
+#include "base/threading/thread.h" |
#include "mojo/public/c/system/main.h" |
#include "mojo/public/cpp/application/application_connection.h" |
#include "mojo/public/cpp/application/application_delegate.h" |
@@ -20,7 +21,9 @@ class HTMLViewer; |
class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { |
public: |
- explicit ContentHandlerImpl(Shell* shell) : shell_(shell) {} |
+ ContentHandlerImpl(Shell* shell, |
+ scoped_refptr<base::MessageLoopProxy> compositor_thread) |
+ : shell_(shell), compositor_thread_(compositor_thread) {} |
virtual ~ContentHandlerImpl() {} |
private: |
@@ -29,40 +32,51 @@ class ContentHandlerImpl : public InterfaceImpl<ContentHandler> { |
const mojo::String& url, |
URLResponsePtr response, |
InterfaceRequest<ServiceProvider> service_provider_request) OVERRIDE { |
- new HTMLDocumentView( |
- response.Pass(), service_provider_request.Pass(), shell_); |
+ new HTMLDocumentView(response.Pass(), |
+ service_provider_request.Pass(), |
+ shell_, |
+ compositor_thread_); |
} |
Shell* shell_; |
+ scoped_refptr<base::MessageLoopProxy> compositor_thread_; |
DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); |
}; |
-class HTMLViewer : public ApplicationDelegate { |
+class HTMLViewer : public ApplicationDelegate, |
+ public InterfaceFactory<ContentHandler> { |
public: |
- HTMLViewer() {} |
+ HTMLViewer() : compositor_thread_("compositor thread") {} |
virtual ~HTMLViewer() { blink::shutdown(); } |
private: |
// Overridden from ApplicationDelegate: |
virtual void Initialize(ApplicationImpl* app) OVERRIDE { |
- content_handler_factory_.reset( |
- new InterfaceFactoryImplWithContext<ContentHandlerImpl, Shell>( |
- app->shell())); |
+ shell_ = app->shell(); |
blink_platform_impl_.reset(new BlinkPlatformImpl(app)); |
blink::initialize(blink_platform_impl_.get()); |
+ compositor_thread_.Start(); |
} |
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
OVERRIDE { |
- connection->AddService(content_handler_factory_.get()); |
+ connection->AddService(this); |
return true; |
} |
+ // Overridden from InterfaceFactory<ContentHandler> |
+ virtual void Create(ApplicationConnection* connection, |
+ InterfaceRequest<ContentHandler> request) OVERRIDE { |
+ BindToRequest( |
+ new ContentHandlerImpl(shell_, compositor_thread_.message_loop_proxy()), |
+ &request); |
+ } |
+ |
scoped_ptr<BlinkPlatformImpl> blink_platform_impl_; |
- scoped_ptr<InterfaceFactoryImplWithContext<ContentHandlerImpl, Shell> > |
- content_handler_factory_; |
+ Shell* shell_; |
+ base::Thread compositor_thread_; |
DISALLOW_COPY_AND_ASSIGN(HTMLViewer); |
}; |