| 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 "sky/viewer/content_handler_impl.h" | 5 #include "sky/viewer/content_handler_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "mojo/public/cpp/application/connect.h" | 8 #include "mojo/public/cpp/application/connect.h" |
| 9 #include "mojo/public/cpp/utility/run_loop.h" |
| 9 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 10 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 10 #include "sky/viewer/document_view.h" | 11 #include "sky/viewer/document_view.h" |
| 11 | 12 |
| 12 namespace sky { | 13 namespace sky { |
| 13 | 14 |
| 14 class SkyApplication : public mojo::Application { | 15 class SkyApplication : public mojo::Application { |
| 15 public: | 16 public: |
| 16 SkyApplication(mojo::ShellPtr shell, | 17 SkyApplication(mojo::ShellPtr shell, |
| 17 mojo::URLResponsePtr response) | 18 mojo::URLResponsePtr response) |
| 18 : url_(response->url), | 19 : url_(response->url), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 45 // raw pointer is needed. | 46 // raw pointer is needed. |
| 46 mojo::URLLoader* raw_loader = loader.get(); | 47 mojo::URLLoader* raw_loader = loader.get(); |
| 47 raw_loader->Start( | 48 raw_loader->Start( |
| 48 request.Pass(), | 49 request.Pass(), |
| 49 base::Bind(&SkyApplication::OnResponseReceived, | 50 base::Bind(&SkyApplication::OnResponseReceived, |
| 50 base::Unretained(this), base::Passed(&loader), | 51 base::Unretained(this), base::Passed(&loader), |
| 51 base::Passed(&services), base::Passed(&exposed_services))); | 52 base::Passed(&services), base::Passed(&exposed_services))); |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 | 55 |
| 56 void RequestQuit() override { |
| 57 mojo::RunLoop::current()->Quit(); |
| 58 } |
| 59 |
| 55 private: | 60 private: |
| 56 void OnResponseReceived( | 61 void OnResponseReceived( |
| 57 mojo::URLLoaderPtr loader, | 62 mojo::URLLoaderPtr loader, |
| 58 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 63 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 59 mojo::ServiceProviderPtr exposed_services, | 64 mojo::ServiceProviderPtr exposed_services, |
| 60 mojo::URLResponsePtr response) { | 65 mojo::URLResponsePtr response) { |
| 61 new DocumentView(services.Pass(), exposed_services.Pass(), response.Pass(), | 66 new DocumentView(services.Pass(), exposed_services.Pass(), response.Pass(), |
| 62 shell_.get()); | 67 shell_.get()); |
| 63 } | 68 } |
| 64 | 69 |
| 65 mojo::String url_; | 70 mojo::String url_; |
| 66 mojo::ShellPtr shell_; | 71 mojo::ShellPtr shell_; |
| 67 mojo::NetworkServicePtr network_service_; | 72 mojo::NetworkServicePtr network_service_; |
| 68 mojo::URLResponsePtr initial_response_; | 73 mojo::URLResponsePtr initial_response_; |
| 69 }; | 74 }; |
| 70 | 75 |
| 71 ContentHandlerImpl::ContentHandlerImpl() { | 76 ContentHandlerImpl::ContentHandlerImpl() { |
| 72 } | 77 } |
| 73 | 78 |
| 74 ContentHandlerImpl::~ContentHandlerImpl() { | 79 ContentHandlerImpl::~ContentHandlerImpl() { |
| 75 } | 80 } |
| 76 | 81 |
| 77 void ContentHandlerImpl::StartApplication(mojo::ShellPtr shell, | 82 void ContentHandlerImpl::StartApplication(mojo::ShellPtr shell, |
| 78 mojo::URLResponsePtr response) { | 83 mojo::URLResponsePtr response) { |
| 79 new SkyApplication(shell.Pass(), response.Pass()); | 84 new SkyApplication(shell.Pass(), response.Pass()); |
| 80 } | 85 } |
| 81 | 86 |
| 82 } // namespace sky | 87 } // namespace sky |
| OLD | NEW |