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

Side by Side Diff: mojo/shell/shell_impl.cc

Issue 1228743002: Mandoline: Move ContentHandlerConnection into separate file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 5 years, 5 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 | « mojo/shell/content_handler_connection.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/shell/shell_impl.h" 5 #include "mojo/shell/shell_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "mojo/application/public/interfaces/content_handler.mojom.h" 9 #include "mojo/application/public/interfaces/content_handler.mojom.h"
10 #include "mojo/common/common_type_converters.h" 10 #include "mojo/common/common_type_converters.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // Shell implementation: 64 // Shell implementation:
65 void ShellImpl::ConnectToApplication(mojo::URLRequestPtr app_request, 65 void ShellImpl::ConnectToApplication(mojo::URLRequestPtr app_request,
66 InterfaceRequest<ServiceProvider> services, 66 InterfaceRequest<ServiceProvider> services,
67 ServiceProviderPtr exposed_services) { 67 ServiceProviderPtr exposed_services) {
68 GURL app_gurl(app_request->url.To<std::string>()); 68 GURL app_gurl(app_request->url.To<std::string>());
69 if (!app_gurl.is_valid()) { 69 if (!app_gurl.is_valid()) {
70 LOG(ERROR) << "Error: invalid URL: " << app_request; 70 LOG(ERROR) << "Error: invalid URL: " << app_request;
71 return; 71 return;
72 } 72 }
73 manager_->ConnectToApplication(app_request.Pass(), identity_.url, 73 manager_->ConnectToApplication(app_request.Pass(), std::string(),
74 services.Pass(), exposed_services.Pass(), 74 identity_.url, services.Pass(),
75 base::Closure()); 75 exposed_services.Pass(), base::Closure());
76 } 76 }
77 77
78 void ShellImpl::QuitApplication() { 78 void ShellImpl::QuitApplication() {
79 queue_requests_ = true; 79 queue_requests_ = true;
80 application_->OnQuitRequested(base::Bind(&ShellImpl::OnQuitRequestedResult, 80 application_->OnQuitRequested(base::Bind(&ShellImpl::OnQuitRequestedResult,
81 base::Unretained(this))); 81 base::Unretained(this)));
82 } 82 }
83 83
84 void ShellImpl::OnConnectionError() { 84 void ShellImpl::OnConnectionError() {
85 std::vector<QueuedClientRequest*> queued_client_requests; 85 std::vector<QueuedClientRequest*> queued_client_requests;
86 queued_client_requests_.swap(queued_client_requests); 86 queued_client_requests_.swap(queued_client_requests);
87 auto manager = manager_; 87 auto manager = manager_;
88 manager_->OnShellImplError(this); 88 manager_->OnShellImplError(this);
89 //|this| is deleted. 89 //|this| is deleted.
90 90
91 // If any queued requests came to shell during time it was shutting down, 91 // If any queued requests came to shell during time it was shutting down,
92 // start them now. 92 // start them now.
93 for (auto request : queued_client_requests) { 93 for (auto request : queued_client_requests) {
94 mojo::URLRequestPtr url(mojo::URLRequest::New()); 94 mojo::URLRequestPtr url(mojo::URLRequest::New());
95 url->url = mojo::String::From(request->requested_url.spec()); 95 url->url = mojo::String::From(request->requested_url.spec());
96 manager->ConnectToApplication(url.Pass(), request->requestor_url, 96 manager->ConnectToApplication(url.Pass(), std::string(),
97 request->requestor_url,
97 request->services.Pass(), 98 request->services.Pass(),
98 request->exposed_services.Pass(), 99 request->exposed_services.Pass(),
99 base::Closure()); 100 base::Closure());
100 } 101 }
101 STLDeleteElements(&queued_client_requests); 102 STLDeleteElements(&queued_client_requests);
102 } 103 }
103 104
104 void ShellImpl::OnQuitRequestedResult(bool can_quit) { 105 void ShellImpl::OnQuitRequestedResult(bool can_quit) {
105 if (can_quit) 106 if (can_quit)
106 return; 107 return;
107 108
108 queue_requests_ = false; 109 queue_requests_ = false;
109 for (auto request : queued_client_requests_) { 110 for (auto request : queued_client_requests_) {
110 application_->AcceptConnection(request->requestor_url.spec(), 111 application_->AcceptConnection(request->requestor_url.spec(),
111 request->services.Pass(), 112 request->services.Pass(),
112 request->exposed_services.Pass(), 113 request->exposed_services.Pass(),
113 request->requested_url.spec()); 114 request->requested_url.spec());
114 } 115 }
115 STLDeleteElements(&queued_client_requests_); 116 STLDeleteElements(&queued_client_requests_);
116 } 117 }
117 118
118 } // namespace shell 119 } // namespace shell
119 } // namespace mojo 120 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/content_handler_connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698