| 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 "base/task_scheduler/post_task.h" | 10 #include "base/task_scheduler/post_task.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 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 int file_descriptor, | 35 int file_descriptor, |
| 36 const GetDebugLogsCallback& callback) override { | 36 const GetDebugLogsCallback& callback) override { |
| 37 // dup() is needed as the file descriptor will be closed on the client side. | 37 // dup() is needed as the file descriptor will be closed on the client side. |
| 38 base::File* file_param = new base::File(dup(file_descriptor)); | 38 base::File* file_param = new base::File(dup(file_descriptor)); |
| 39 base::PostTaskWithTraitsAndReply( | 39 base::PostTaskWithTraitsAndReply( |
| 40 FROM_HERE, base::TaskTraits().MayBlock(), | 40 FROM_HERE, {base::MayBlock()}, |
| 41 base::Bind(&GenerateTestLogDumpFile, test_file_, | 41 base::Bind(&GenerateTestLogDumpFile, test_file_, |
| 42 base::Owned(file_param)), | 42 base::Owned(file_param)), |
| 43 base::Bind(callback, true)); | 43 base::Bind(callback, true)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 static void GenerateTestLogDumpFile(const base::FilePath& test_tar_file, | 46 static void GenerateTestLogDumpFile(const base::FilePath& test_tar_file, |
| 47 base::File* file) { | 47 base::File* file) { |
| 48 std::string test_file_content; | 48 std::string test_file_content; |
| 49 EXPECT_TRUE(base::ReadFileToString(test_tar_file, &test_file_content)) | 49 EXPECT_TRUE(base::ReadFileToString(test_tar_file, &test_file_content)) |
| 50 << "Cannot read content of file " << test_tar_file.value(); | 50 << "Cannot read content of file " << test_tar_file.value(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 IN_PROC_BROWSER_TEST_F(LogPrivateApiTest, DumpLogsAndCaptureEvents) { | 91 IN_PROC_BROWSER_TEST_F(LogPrivateApiTest, DumpLogsAndCaptureEvents) { |
| 92 // Setup dummy HTTP server. | 92 // Setup dummy HTTP server. |
| 93 embedded_test_server()->RegisterRequestHandler( | 93 embedded_test_server()->RegisterRequestHandler( |
| 94 base::Bind(&LogPrivateApiTest::HandleRequest, base::Unretained(this))); | 94 base::Bind(&LogPrivateApiTest::HandleRequest, base::Unretained(this))); |
| 95 ASSERT_TRUE(StartEmbeddedTestServer()); | 95 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 96 | 96 |
| 97 ASSERT_TRUE(RunExtensionTest("log_private/dump_logs")); | 97 ASSERT_TRUE(RunExtensionTest("log_private/dump_logs")); |
| 98 } | 98 } |
| 99 | 99 |
| 100 } // namespace extensions | 100 } // namespace extensions |
| OLD | NEW |