| 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 "chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.h" | 5 #include "chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.h" |
| 6 | 6 |
| 7 #include <mach-o/loader.h> | 7 #include <mach-o/loader.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 base::FilePath GetFilePath(const char* file_name) { | 41 base::FilePath GetFilePath(const char* file_name) { |
| 42 base::FilePath test_data; | 42 base::FilePath test_data; |
| 43 EXPECT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &test_data)); | 43 EXPECT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA, &test_data)); |
| 44 return test_data.AppendASCII("chrome") | 44 return test_data.AppendASCII("chrome") |
| 45 .AppendASCII("safe_browsing_dmg") | 45 .AppendASCII("safe_browsing_dmg") |
| 46 .AppendASCII(file_name); | 46 .AppendASCII(file_name); |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 // A helper class to store the results from the ResultsCallback and run | 50 // A helper that provides a SandboxedDMGAnalyzer::ResultCallback that will |
| 51 // another closure. | 51 // store a copy of an analyzer's results and then run a closure. |
| 52 class ResultsGetter { | 52 class ResultsGetter { |
| 53 public: | 53 public: |
| 54 ResultsGetter(const base::Closure& next_closure, | 54 ResultsGetter(const base::Closure& next_closure, |
| 55 zip_analyzer::Results* results) | 55 zip_analyzer::Results* results) |
| 56 : next_closure_(next_closure), results_(results) {} | 56 : next_closure_(next_closure), results_(results) {} |
| 57 | 57 |
| 58 SandboxedDMGAnalyzer::ResultsCallback GetCallback() { | 58 SandboxedDMGAnalyzer::ResultCallback GetCallback() { |
| 59 return base::Bind(&ResultsGetter::ResultsCallback, | 59 return base::Bind(&ResultsGetter::ResultsCallback, |
| 60 base::Unretained(this)); | 60 base::Unretained(this)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 void ResultsCallback(const zip_analyzer::Results& results) { | 64 void ResultsCallback(const zip_analyzer::Results& results) { |
| 65 *results_ = results; | 65 *results_ = results; |
| 66 next_closure_.Run(); | 66 next_closure_.Run(); |
| 67 } | 67 } |
| 68 | 68 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 ADD_FAILURE() << "Unepxected result file " << binary.file_basename(); | 136 ADD_FAILURE() << "Unepxected result file " << binary.file_basename(); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 EXPECT_TRUE(got_executable); | 140 EXPECT_TRUE(got_executable); |
| 141 EXPECT_TRUE(got_dylib); | 141 EXPECT_TRUE(got_dylib); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace | 144 } // namespace |
| 145 } // namespace safe_browsing | 145 } // namespace safe_browsing |
| OLD | NEW |