Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: sky/viewer/content_handler_impl.cc

Issue 853303004: Add Application::RequestQuit() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: commentary Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « shell/external_application_listener_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « shell/external_application_listener_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698