Chromium Code Reviews| 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 <string> | 5 #include <string> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 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 "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 class TestDebugDaemonClient : public chromeos::FakeDebugDaemonClient { | 27 class TestDebugDaemonClient : public chromeos::FakeDebugDaemonClient { |
| 28 public: | 28 public: |
| 29 explicit TestDebugDaemonClient(const base::FilePath& test_file) | 29 explicit TestDebugDaemonClient(const base::FilePath& test_file) |
| 30 : test_file_(test_file) {} | 30 : test_file_(test_file) {} |
| 31 | 31 |
| 32 ~TestDebugDaemonClient() override {} | 32 ~TestDebugDaemonClient() override {} |
| 33 | 33 |
| 34 void DumpDebugLogs(bool is_compressed, | 34 void DumpDebugLogs(bool is_compressed, |
| 35 base::File file, | 35 int file_descriptor, |
| 36 scoped_refptr<base::TaskRunner> task_runner, | |
| 37 const GetDebugLogsCallback& callback) override { | 36 const GetDebugLogsCallback& callback) override { |
| 38 base::File* file_param = new base::File(std::move(file)); | 37 base::File* file_param = new base::File(dup(file_descriptor)); |
|
satorux1
2016/08/23 07:02:02
I think it's not so obvious why dup() is needed he
hashimoto
2016/08/23 07:41:27
Done.
| |
| 39 task_runner->PostTaskAndReply( | 38 content::BrowserThread::PostBlockingPoolTaskAndReply( |
| 40 FROM_HERE, | 39 FROM_HERE, base::Bind(&GenerateTestLogDumpFile, test_file_, |
| 41 base::Bind( | 40 base::Owned(file_param)), |
| 42 &GenerateTestLogDumpFile, test_file_, base::Owned(file_param)), | |
| 43 base::Bind(callback, true)); | 41 base::Bind(callback, true)); |
| 44 } | 42 } |
| 45 | 43 |
| 46 static void GenerateTestLogDumpFile(const base::FilePath& test_tar_file, | 44 static void GenerateTestLogDumpFile(const base::FilePath& test_tar_file, |
| 47 base::File* file) { | 45 base::File* file) { |
| 48 std::string test_file_content; | 46 std::string test_file_content; |
| 49 EXPECT_TRUE(base::ReadFileToString(test_tar_file, &test_file_content)) | 47 EXPECT_TRUE(base::ReadFileToString(test_tar_file, &test_file_content)) |
| 50 << "Cannot read content of file " << test_tar_file.value(); | 48 << "Cannot read content of file " << test_tar_file.value(); |
| 51 const int data_size = static_cast<int>(test_file_content.size()); | 49 const int data_size = static_cast<int>(test_file_content.size()); |
| 52 EXPECT_EQ(data_size, file->Write(0, test_file_content.data(), data_size)); | 50 EXPECT_EQ(data_size, file->Write(0, test_file_content.data(), data_size)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // Setup dummy HTTP server. | 89 // Setup dummy HTTP server. |
| 92 host_resolver()->AddRule("www.test.com", "127.0.0.1"); | 90 host_resolver()->AddRule("www.test.com", "127.0.0.1"); |
| 93 ASSERT_TRUE(StartEmbeddedTestServer()); | 91 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 94 embedded_test_server()->RegisterRequestHandler( | 92 embedded_test_server()->RegisterRequestHandler( |
| 95 base::Bind(&LogPrivateApiTest::HandleRequest, base::Unretained(this))); | 93 base::Bind(&LogPrivateApiTest::HandleRequest, base::Unretained(this))); |
| 96 | 94 |
| 97 ASSERT_TRUE(RunExtensionTest("log_private/dump_logs")); | 95 ASSERT_TRUE(RunExtensionTest("log_private/dump_logs")); |
| 98 } | 96 } |
| 99 | 97 |
| 100 } // namespace extensions | 98 } // namespace extensions |
| OLD | NEW |