| OLD | NEW |
| 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 <iostream> | 5 #include <iostream> |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 << " <sky-app>" << std::endl; | 24 << " <sky-app>" << std::endl; |
| 25 } | 25 } |
| 26 | 26 |
| 27 void WriteSnapshot(base::FilePath path) { | 27 void WriteSnapshot(base::FilePath path) { |
| 28 uint8_t* buffer; | 28 uint8_t* buffer; |
| 29 intptr_t size; | 29 intptr_t size; |
| 30 CHECK(!LogIfError(Dart_CreateScriptSnapshot(&buffer, &size))); | 30 CHECK(!LogIfError(Dart_CreateScriptSnapshot(&buffer, &size))); |
| 31 | 31 |
| 32 CHECK_EQ(base::WriteFile(path, reinterpret_cast<const char*>(buffer), size), | 32 CHECK_EQ(base::WriteFile(path, reinterpret_cast<const char*>(buffer), size), |
| 33 size); | 33 size); |
| 34 | |
| 35 std::cout << "Successfully wrote snapshot to " << path.LossyDisplayName() | |
| 36 << " (" << size << " bytes)." << std::endl; | |
| 37 } | 34 } |
| 38 | 35 |
| 39 int main(int argc, const char* argv[]) { | 36 int main(int argc, const char* argv[]) { |
| 40 base::AtExitManager exit_manager; | 37 base::AtExitManager exit_manager; |
| 41 base::EnableTerminationOnHeapCorruption(); | 38 base::EnableTerminationOnHeapCorruption(); |
| 42 base::CommandLine::Init(argc, argv); | 39 base::CommandLine::Init(argc, argv); |
| 43 | 40 |
| 44 const base::CommandLine& command_line = | 41 const base::CommandLine& command_line = |
| 45 *base::CommandLine::ForCurrentProcess(); | 42 *base::CommandLine::ForCurrentProcess(); |
| 46 | 43 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 61 CHECK(args.size() == 1); | 58 CHECK(args.size() == 1); |
| 62 LoadScript(args[0]); | 59 LoadScript(args[0]); |
| 63 | 60 |
| 64 CHECK(!LogIfError(Dart_FinalizeLoading(true))); | 61 CHECK(!LogIfError(Dart_FinalizeLoading(true))); |
| 65 | 62 |
| 66 CHECK(command_line.HasSwitch(switches::kSnapshot)) << "Need --snapshot"; | 63 CHECK(command_line.HasSwitch(switches::kSnapshot)) << "Need --snapshot"; |
| 67 WriteSnapshot(command_line.GetSwitchValuePath(switches::kSnapshot)); | 64 WriteSnapshot(command_line.GetSwitchValuePath(switches::kSnapshot)); |
| 68 | 65 |
| 69 return 0; | 66 return 0; |
| 70 } | 67 } |
| OLD | NEW |