| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/application/content_handler_factory.h" | 5 #include "mojo/application/content_handler_factory.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "mojo/application/application_runner_chromium.h" | 15 #include "mojo/application/application_runner_chromium.h" |
| 16 #include "mojo/message_pump/message_pump_mojo.h" | 16 #include "mojo/message_pump/message_pump_mojo.h" |
| 17 #include "mojo/public/cpp/application/application_delegate.h" | 17 #include "mojo/public/cpp/application/application_delegate.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 ContentHandlerFactory::Delegate* delegate_; | 104 ContentHandlerFactory::Delegate* delegate_; |
| 105 std::map<ApplicationThread*, base::PlatformThreadHandle> active_threads_; | 105 std::map<ApplicationThread*, base::PlatformThreadHandle> active_threads_; |
| 106 StrongBinding<ContentHandler> binding_; | 106 StrongBinding<ContentHandler> binding_; |
| 107 base::WeakPtrFactory<ContentHandlerImpl> weak_factory_; | 107 base::WeakPtrFactory<ContentHandlerImpl> weak_factory_; |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); | 109 DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace | 112 } // namespace |
| 113 | 113 |
| 114 ContentHandlerFactory::ContentHandlerFactory(Delegate* delegate) | 114 // static |
| 115 : delegate_(delegate) {} | |
| 116 | |
| 117 ContentHandlerFactory::~ContentHandlerFactory() {} | |
| 118 | |
| 119 void ContentHandlerFactory::Create( | |
| 120 const ConnectionContext& connection_context, | |
| 121 InterfaceRequest<ContentHandler> content_handler_request) { | |
| 122 new ContentHandlerImpl(delegate_, content_handler_request.Pass()); | |
| 123 } | |
| 124 | |
| 125 ServiceProviderImpl::InterfaceRequestHandler<ContentHandler> | 115 ServiceProviderImpl::InterfaceRequestHandler<ContentHandler> |
| 126 ContentHandlerFactory::GetInterfaceRequestHandler() { | 116 ContentHandlerFactory::GetInterfaceRequestHandler(Delegate* delegate) { |
| 127 return [this](const ConnectionContext& connection_context, | 117 return [delegate](const ConnectionContext& connection_context, |
| 128 InterfaceRequest<ContentHandler> content_handler_request) { | 118 InterfaceRequest<ContentHandler> content_handler_request) { |
| 129 Create(connection_context, content_handler_request.Pass()); | 119 new ContentHandlerImpl(delegate, content_handler_request.Pass()); |
| 130 }; | 120 }; |
| 131 } | 121 } |
| 132 | 122 |
| 133 void ContentHandlerFactory::ManagedDelegate::RunApplication( | 123 void ContentHandlerFactory::ManagedDelegate::RunApplication( |
| 134 InterfaceRequest<Application> application_request, | 124 InterfaceRequest<Application> application_request, |
| 135 URLResponsePtr response) { | 125 URLResponsePtr response) { |
| 136 base::MessageLoop loop(common::MessagePumpMojo::Create()); | 126 base::MessageLoop loop(common::MessagePumpMojo::Create()); |
| 137 auto application = | 127 auto application = |
| 138 this->CreateApplication(application_request.Pass(), response.Pass()); | 128 this->CreateApplication(application_request.Pass(), response.Pass()); |
| 139 if (application) | 129 if (application) |
| 140 loop.Run(); | 130 loop.Run(); |
| 141 } | 131 } |
| 142 | 132 |
| 143 } // namespace mojo | 133 } // namespace mojo |
| OLD | NEW |