| 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 "services/dart/dart_app.h" | 5 #include "services/dart/dart_app.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 DartApp::DartApp(mojo::InterfaceRequest<Application> application_request, | 23 DartApp::DartApp(mojo::InterfaceRequest<Application> application_request, |
| 24 mojo::URLResponsePtr response, | 24 mojo::URLResponsePtr response, |
| 25 bool strict) | 25 bool strict) |
| 26 : application_request_(application_request.Pass()) { | 26 : application_request_(application_request.Pass()) { |
| 27 DCHECK(!response.is_null()); | 27 DCHECK(!response.is_null()); |
| 28 std::string url(response->url); | 28 std::string url(response->url); |
| 29 | 29 |
| 30 CHECK(unpacked_app_directory_.CreateUniqueTempDir()); | 30 CHECK(unpacked_app_directory_.CreateUniqueTempDir()); |
| 31 ExtractApplication(response.Pass()); | 31 ExtractApplication(response.Pass()); |
| 32 base::FilePath package_root = unpacked_app_directory_.path(); | 32 base::FilePath package_root = |
| 33 unpacked_app_directory_.path().AppendASCII("packages"); |
| 33 | 34 |
| 34 base::FilePath entry_path = package_root.Append("main.dart"); | 35 base::FilePath entry_path = |
| 36 unpacked_app_directory_.path().Append("main.dart"); |
| 35 std::string source; | 37 std::string source; |
| 36 if (!base::ReadFileToString(entry_path, &source)) { | 38 if (!base::ReadFileToString(entry_path, &source)) { |
| 37 NOTREACHED(); | 39 NOTREACHED(); |
| 38 return; | 40 return; |
| 39 } | 41 } |
| 40 | 42 |
| 41 config_.application_data = reinterpret_cast<void*>(this); | 43 config_.application_data = reinterpret_cast<void*>(this); |
| 42 config_.strict_compilation = strict; | 44 config_.strict_compilation = strict; |
| 43 config_.script = source; | 45 config_.script = source; |
| 44 config_.script_uri = entry_path.AsUTF8Unsafe(); | 46 config_.script_uri = entry_path.AsUTF8Unsafe(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 82 } |
| 81 | 83 |
| 82 std::string DartApp::CopyToString(mojo::ScopedDataPipeConsumerHandle body) { | 84 std::string DartApp::CopyToString(mojo::ScopedDataPipeConsumerHandle body) { |
| 83 std::string body_str; | 85 std::string body_str; |
| 84 bool result = mojo::common::BlockingCopyToString(body.Pass(), &body_str); | 86 bool result = mojo::common::BlockingCopyToString(body.Pass(), &body_str); |
| 85 DCHECK(result); | 87 DCHECK(result); |
| 86 return body_str; | 88 return body_str; |
| 87 } | 89 } |
| 88 | 90 |
| 89 } // namespace dart | 91 } // namespace dart |
| OLD | NEW |