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

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

Issue 2010283006: Almost done: ApplicationDelegate -> ApplicationImplBase conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@work798-x-work797-x-work796_no_run_main_app
Patch Set: rebased Created 4 years, 6 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
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 #include "services/dart/content_handler_app.h" 4 #include "services/dart/content_handler_app.h"
5 5
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"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "mojo/dart/embedder/dart_controller.h" 12 #include "mojo/dart/embedder/dart_controller.h"
13 #include "mojo/public/cpp/application/application_impl.h"
14 #include "mojo/public/cpp/application/connect.h" 13 #include "mojo/public/cpp/application/connect.h"
14 #include "mojo/public/cpp/application/service_provider_impl.h"
15 #include "mojo/public/cpp/bindings/binding.h" 15 #include "mojo/public/cpp/bindings/binding.h"
16 #include "mojo/public/cpp/bindings/interface_request.h" 16 #include "mojo/public/cpp/bindings/interface_request.h"
17 #include "mojo/services/tracing/interfaces/tracing.mojom.h" 17 #include "mojo/services/tracing/interfaces/tracing.mojom.h"
18 #include "services/dart/dart_app.h" 18 #include "services/dart/dart_app.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 namespace dart { 21 namespace dart {
22 22
23 // Flags for the content handler: 23 // Flags for the content handler:
24 const char kDartTimeline[] = "--dart-timeline"; 24 const char kDartTimeline[] = "--dart-timeline";
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 application_dir_path.size())); 123 application_dir_path.size()));
124 } 124 }
125 callback.Run(); 125 callback.Run();
126 }); 126 });
127 } 127 }
128 128
129 bool DartContentHandlerApp::run_on_message_loop() const { 129 bool DartContentHandlerApp::run_on_message_loop() const {
130 return run_on_message_loop_; 130 return run_on_message_loop_;
131 } 131 }
132 132
133 void DartContentHandlerApp::Initialize(mojo::ApplicationImpl* app) { 133 void DartContentHandlerApp::OnInitialize() {
134 // Tracing of content handler and controller. 134 // Tracing of content handler and controller.
135 tracing_.Initialize(app->shell(), &app->args()); 135 tracing_.Initialize(shell(), &args());
136 // Tracing of isolates and VM. 136 // Tracing of isolates and VM.
137 dart_tracing_.Initialize(app->shell()); 137 dart_tracing_.Initialize(shell());
138 138
139 // TODO(qsr): This has no effect for now, as the tracing infrastructure 139 // TODO(qsr): This has no effect for now, as the tracing infrastructure
140 // doesn't allow to trace anything before the tracing app connects to the 140 // doesn't allow to trace anything before the tracing app connects to the
141 // application. 141 // application.
142 TRACE_EVENT0("dart_content_handler", "DartContentHandler::Initialize"); 142 TRACE_EVENT0("dart_content_handler", "DartContentHandler::Initialize");
143 143
144 default_strict_ = app->HasArg(kEnableStrictMode); 144 default_strict_ = HasArg(kEnableStrictMode);
145 content_handler_.set_handler_task_runner( 145 content_handler_.set_handler_task_runner(
146 base::MessageLoop::current()->task_runner()); 146 base::MessageLoop::current()->task_runner());
147 strict_content_handler_.set_handler_task_runner( 147 strict_content_handler_.set_handler_task_runner(
148 base::MessageLoop::current()->task_runner()); 148 base::MessageLoop::current()->task_runner());
149 mojo::ConnectToService(app->shell(), "mojo:url_response_disk_cache", 149 mojo::ConnectToService(shell(), "mojo:url_response_disk_cache",
150 GetProxy(&url_response_disk_cache_)); 150 GetProxy(&url_response_disk_cache_));
151 service_connector_ = new ContentHandlerAppServiceConnector(app); 151 service_connector_ = new ContentHandlerAppServiceConnector(shell());
152 152
153 if (app->HasArg(kRunOnMessageLoop)) { 153 if (HasArg(kRunOnMessageLoop)) {
154 run_on_message_loop_ = true; 154 run_on_message_loop_ = true;
155 } 155 }
156 156
157 bool enable_observatory = true; 157 bool enable_observatory = true;
158 if (app->HasArg(kDisableObservatory)) { 158 if (HasArg(kDisableObservatory)) {
159 enable_observatory = false; 159 enable_observatory = false;
160 } 160 }
161 161
162 bool enable_dart_timeline = false; 162 bool enable_dart_timeline = false;
163 if (app->HasArg(kDartTimeline)) { 163 if (HasArg(kDartTimeline)) {
164 enable_dart_timeline = true; 164 enable_dart_timeline = true;
165 } 165 }
166 166
167 std::vector<const char*> extra_args; 167 std::vector<const char*> extra_args;
168 168
169 if (app->HasArg(kPauseIsolatesOnStart)) { 169 if (HasArg(kPauseIsolatesOnStart)) {
170 extra_args.push_back(kPauseIsolatesOnStart); 170 extra_args.push_back(kPauseIsolatesOnStart);
171 } 171 }
172 172
173 if (app->HasArg(kPauseIsolatesOnExit)) { 173 if (HasArg(kPauseIsolatesOnExit)) {
174 extra_args.push_back(kPauseIsolatesOnExit); 174 extra_args.push_back(kPauseIsolatesOnExit);
175 } 175 }
176 176
177 if (app->HasArg(kCompleteTimeline)) { 177 if (HasArg(kCompleteTimeline)) {
178 extra_args.push_back(kCompleteTimeline); 178 extra_args.push_back(kCompleteTimeline);
179 } 179 }
180 180
181 bool success = mojo::dart::DartController::Initialize( 181 bool success = mojo::dart::DartController::Initialize(
182 service_connector_, default_strict_, enable_observatory, 182 service_connector_, default_strict_, enable_observatory,
183 enable_dart_timeline, extra_args.data(), extra_args.size()); 183 enable_dart_timeline, extra_args.data(), extra_args.size());
184 184
185 if (app->HasArg(kTraceStartup)) { 185 if (HasArg(kTraceStartup)) {
186 DartTimelineController::EnableAll(); 186 DartTimelineController::EnableAll();
187 } 187 }
188 if (!success) { 188 if (!success) {
189 LOG(ERROR) << "Dart VM Initialization failed"; 189 LOG(ERROR) << "Dart VM Initialization failed";
190 } 190 }
191 } 191 }
192 192
193 bool DartContentHandlerApp::ConfigureIncomingConnection( 193 bool DartContentHandlerApp::OnAcceptConnection(
194 mojo::ServiceProviderImpl* service_provider_impl) { 194 mojo::ServiceProviderImpl* service_provider_impl) {
195 bool strict = HasStrictQueryParam( 195 bool strict = HasStrictQueryParam(
196 service_provider_impl->connection_context().connection_url); 196 service_provider_impl->connection_context().connection_url);
197 if (default_strict_ || strict) { 197 if (default_strict_ || strict) {
198 service_provider_impl->AddService<mojo::ContentHandler>( 198 service_provider_impl->AddService<mojo::ContentHandler>(
199 mojo::ContentHandlerFactory::GetInterfaceRequestHandler( 199 mojo::ContentHandlerFactory::GetInterfaceRequestHandler(
200 &strict_content_handler_)); 200 &strict_content_handler_));
201 } else { 201 } else {
202 service_provider_impl->AddService<mojo::ContentHandler>( 202 service_provider_impl->AddService<mojo::ContentHandler>(
203 mojo::ContentHandlerFactory::GetInterfaceRequestHandler( 203 mojo::ContentHandlerFactory::GetInterfaceRequestHandler(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } else { 251 } else {
252 // Loading a raw .dart file pointed at by |url|. 252 // Loading a raw .dart file pointed at by |url|.
253 return make_scoped_ptr( 253 return make_scoped_ptr(
254 new DartApp(application_request.Pass(), url, strict_, 254 new DartApp(application_request.Pass(), url, strict_,
255 run_on_message_loop, override_pause_isolates_flags, 255 run_on_message_loop, override_pause_isolates_flags,
256 pause_isolates_on_start, pause_isolates_on_exit)); 256 pause_isolates_on_start, pause_isolates_on_exit));
257 } 257 }
258 } 258 }
259 259
260 } // namespace dart 260 } // namespace dart
OLDNEW
« no previous file with comments | « services/dart/content_handler_app.h ('k') | services/dart/content_handler_app_service_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698