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

Side by Side Diff: services/dart/content_handler_main.cc

Issue 1993053002: Simplify ContentHandlerFactory a bit. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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/application/content_handler_factory.cc ('k') | services/java_handler/java_handler.h » ('j') | 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 scoped_refptr<base::SingleThreadTaskRunner> handler_task_runner_; 128 scoped_refptr<base::SingleThreadTaskRunner> handler_task_runner_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(DartContentHandler); 130 DISALLOW_COPY_AND_ASSIGN(DartContentHandler);
131 }; 131 };
132 132
133 class DartContentHandlerApp : public mojo::ApplicationDelegate { 133 class DartContentHandlerApp : public mojo::ApplicationDelegate {
134 public: 134 public:
135 DartContentHandlerApp() 135 DartContentHandlerApp()
136 : content_handler_(this, false), 136 : content_handler_(this, false),
137 strict_content_handler_(this, true), 137 strict_content_handler_(this, true),
138 content_handler_factory_(&content_handler_),
139 strict_content_handler_factory_(&strict_content_handler_),
140 service_connector_(nullptr), 138 service_connector_(nullptr),
141 default_strict_(false), 139 default_strict_(false),
142 run_on_message_loop_(false) {} 140 run_on_message_loop_(false) {}
143 141
144 ~DartContentHandlerApp() override { 142 ~DartContentHandlerApp() override {
145 // Shutdown the controller. 143 // Shutdown the controller.
146 mojo::dart::DartController::Shutdown(); 144 mojo::dart::DartController::Shutdown();
147 delete service_connector_; 145 delete service_connector_;
148 } 146 }
149 147
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 233 }
236 } 234 }
237 235
238 // Overridden from ApplicationDelegate: 236 // Overridden from ApplicationDelegate:
239 bool ConfigureIncomingConnection( 237 bool ConfigureIncomingConnection(
240 mojo::ServiceProviderImpl* service_provider_impl) override { 238 mojo::ServiceProviderImpl* service_provider_impl) override {
241 bool strict = HasStrictQueryParam( 239 bool strict = HasStrictQueryParam(
242 service_provider_impl->connection_context().connection_url); 240 service_provider_impl->connection_context().connection_url);
243 if (default_strict_ || strict) { 241 if (default_strict_ || strict) {
244 service_provider_impl->AddService<mojo::ContentHandler>( 242 service_provider_impl->AddService<mojo::ContentHandler>(
245 strict_content_handler_factory_.GetInterfaceRequestHandler()); 243 mojo::ContentHandlerFactory::GetInterfaceRequestHandler(
244 &strict_content_handler_));
246 } else { 245 } else {
247 service_provider_impl->AddService<mojo::ContentHandler>( 246 service_provider_impl->AddService<mojo::ContentHandler>(
248 content_handler_factory_.GetInterfaceRequestHandler()); 247 mojo::ContentHandlerFactory::GetInterfaceRequestHandler(
248 &content_handler_));
249 } 249 }
250 return true; 250 return true;
251 } 251 }
252 252
253 mojo::TracingImpl tracing_; 253 mojo::TracingImpl tracing_;
254 DartContentHandler content_handler_; 254 DartContentHandler content_handler_;
255 DartContentHandler strict_content_handler_; 255 DartContentHandler strict_content_handler_;
256 mojo::ContentHandlerFactory content_handler_factory_;
257 mojo::ContentHandlerFactory strict_content_handler_factory_;
258 mojo::URLResponseDiskCachePtr url_response_disk_cache_; 256 mojo::URLResponseDiskCachePtr url_response_disk_cache_;
259 ContentHandlerAppServiceConnector* service_connector_; 257 ContentHandlerAppServiceConnector* service_connector_;
260 DartTracingImpl dart_tracing_; 258 DartTracingImpl dart_tracing_;
261 bool default_strict_; 259 bool default_strict_;
262 bool run_on_message_loop_; 260 bool run_on_message_loop_;
263 261
264 DISALLOW_COPY_AND_ASSIGN(DartContentHandlerApp); 262 DISALLOW_COPY_AND_ASSIGN(DartContentHandlerApp);
265 }; 263 };
266 264
267 scoped_ptr<mojo::ContentHandlerFactory::HandledApplicationHolder> 265 scoped_ptr<mojo::ContentHandlerFactory::HandledApplicationHolder>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 pause_isolates_on_exit)); 323 pause_isolates_on_exit));
326 } 324 }
327 } 325 }
328 326
329 } // namespace dart 327 } // namespace dart
330 328
331 MojoResult MojoMain(MojoHandle application_request) { 329 MojoResult MojoMain(MojoHandle application_request) {
332 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandlerApp); 330 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandlerApp);
333 return runner.Run(application_request); 331 return runner.Run(application_request);
334 } 332 }
OLDNEW
« no previous file with comments | « mojo/application/content_handler_factory.cc ('k') | services/java_handler/java_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698