| 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 "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_util.h" | 8 #include "base/strings/string_util.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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 mojo::URLResponsePtr response) { | 158 mojo::URLResponsePtr response) { |
| 159 base::trace_event::TraceLog::GetInstance() | 159 base::trace_event::TraceLog::GetInstance() |
| 160 ->SetCurrentThreadBlocksMessageLoop(); | 160 ->SetCurrentThreadBlocksMessageLoop(); |
| 161 | 161 |
| 162 TRACE_EVENT1("dart_content_handler", "DartContentHandler::CreateApplication", | 162 TRACE_EVENT1("dart_content_handler", "DartContentHandler::CreateApplication", |
| 163 "url", response->url.get()); | 163 "url", response->url.get()); |
| 164 | 164 |
| 165 base::FilePath application_dir; | 165 base::FilePath application_dir; |
| 166 std::string url = response->url.get(); | 166 std::string url = response->url.get(); |
| 167 if (IsDartZip(response->url.get())) { | 167 if (IsDartZip(response->url.get())) { |
| 168 // Loading a .dartzip: | 168 // Loading a zipped snapshot: |
| 169 // 1) Extract the .dartzip | 169 // 1) Extract the zip file. |
| 170 // 2) Launch from temporary directory (|application_dir|). | 170 // 2) Launch from temporary directory (|application_dir|). |
| 171 handler_task_runner_->PostTask( | 171 handler_task_runner_->PostTask( |
| 172 FROM_HERE, | 172 FROM_HERE, |
| 173 base::Bind( | 173 base::Bind( |
| 174 &DartContentHandlerApp::ExtractApplication, base::Unretained(app_), | 174 &DartContentHandlerApp::ExtractApplication, base::Unretained(app_), |
| 175 base::Unretained(&application_dir), base::Passed(response.Pass()), | 175 base::Unretained(&application_dir), base::Passed(response.Pass()), |
| 176 base::Bind( | 176 base::Bind( |
| 177 base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), | 177 base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), |
| 178 base::MessageLoop::current()->task_runner(), FROM_HERE, | 178 base::MessageLoop::current()->task_runner(), FROM_HERE, |
| 179 base::MessageLoop::QuitWhenIdleClosure()))); | 179 base::MessageLoop::QuitWhenIdleClosure()))); |
| 180 base::RunLoop().Run(); | 180 base::RunLoop().Run(); |
| 181 return make_scoped_ptr( | 181 return make_scoped_ptr( |
| 182 new DartApp(application_request.Pass(), application_dir, strict_)); | 182 new DartApp(application_request.Pass(), application_dir, strict_)); |
| 183 } else { | 183 } else { |
| 184 // Loading a raw .dart file pointed at by |url|. | 184 // Loading a raw .dart file pointed at by |url|. |
| 185 return make_scoped_ptr( | 185 return make_scoped_ptr( |
| 186 new DartApp(application_request.Pass(), url, strict_)); | 186 new DartApp(application_request.Pass(), url, strict_)); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 } // namespace dart | 190 } // namespace dart |
| 191 | 191 |
| 192 MojoResult MojoMain(MojoHandle application_request) { | 192 MojoResult MojoMain(MojoHandle application_request) { |
| 193 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandlerApp); | 193 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandlerApp); |
| 194 MojoResult r = runner.Run(application_request); | 194 MojoResult r = runner.Run(application_request); |
| 195 // TODO(johnmccutchan): Remove this once the Dart VM shuts down threads. | 195 // TODO(johnmccutchan): Remove this once the Dart VM shuts down threads. |
| 196 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); | 196 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); |
| 197 return r; | 197 return r; |
| 198 } | 198 } |
| OLD | NEW |