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 "chrome/browser/media/webrtc_rtp_dump_handler.h" |
| 6 |
5 #include <stddef.h> | 7 #include <stddef.h> |
6 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> |
7 | 10 |
8 #include "base/bind.h" | 11 #include "base/bind.h" |
9 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
11 #include "base/location.h" | 14 #include "base/location.h" |
12 #include "base/macros.h" | 15 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
14 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
15 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
16 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
17 #include "chrome/browser/media/webrtc_rtp_dump_handler.h" | |
18 #include "chrome/browser/media/webrtc_rtp_dump_writer.h" | 20 #include "chrome/browser/media/webrtc_rtp_dump_writer.h" |
19 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
22 | 24 |
23 class FakeDumpWriter : public WebRtcRtpDumpWriter { | 25 class FakeDumpWriter : public WebRtcRtpDumpWriter { |
24 public: | 26 public: |
25 FakeDumpWriter(size_t max_dump_size, | 27 FakeDumpWriter(size_t max_dump_size, |
26 const base::Closure& max_size_reached_callback, | 28 const base::Closure& max_size_reached_callback, |
27 bool end_dump_success) | 29 bool end_dump_success) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 void ResetDumpHandler(const base::FilePath& dir, bool end_dump_success) { | 77 void ResetDumpHandler(const base::FilePath& dir, bool end_dump_success) { |
76 handler_.reset(new WebRtcRtpDumpHandler( | 78 handler_.reset(new WebRtcRtpDumpHandler( |
77 dir.empty() ? base::FilePath(FILE_PATH_LITERAL("dummy")) : dir)); | 79 dir.empty() ? base::FilePath(FILE_PATH_LITERAL("dummy")) : dir)); |
78 | 80 |
79 scoped_ptr<WebRtcRtpDumpWriter> writer(new FakeDumpWriter( | 81 scoped_ptr<WebRtcRtpDumpWriter> writer(new FakeDumpWriter( |
80 10, | 82 10, |
81 base::Bind(&WebRtcRtpDumpHandler::OnMaxDumpSizeReached, | 83 base::Bind(&WebRtcRtpDumpHandler::OnMaxDumpSizeReached, |
82 base::Unretained(handler_.get())), | 84 base::Unretained(handler_.get())), |
83 end_dump_success)); | 85 end_dump_success)); |
84 | 86 |
85 handler_->SetDumpWriterForTesting(writer.Pass()); | 87 handler_->SetDumpWriterForTesting(std::move(writer)); |
86 } | 88 } |
87 | 89 |
88 void DeleteDumpHandler() { handler_.reset(); } | 90 void DeleteDumpHandler() { handler_.reset(); } |
89 | 91 |
90 void WriteFakeDumpFiles(const base::FilePath& dir, | 92 void WriteFakeDumpFiles(const base::FilePath& dir, |
91 base::FilePath* incoming_dump, | 93 base::FilePath* incoming_dump, |
92 base::FilePath* outgoing_dump) { | 94 base::FilePath* outgoing_dump) { |
93 *incoming_dump = dir.AppendASCII("recv"); | 95 *incoming_dump = dir.AppendASCII("recv"); |
94 *outgoing_dump = dir.AppendASCII("send"); | 96 *outgoing_dump = dir.AppendASCII("send"); |
95 const char dummy[] = "dummy"; | 97 const char dummy[] = "dummy"; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler)); | 410 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler)); |
409 | 411 |
410 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); | 412 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); |
411 | 413 |
412 handler_->StopOngoingDumps( | 414 handler_->StopOngoingDumps( |
413 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished, | 415 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished, |
414 base::Unretained(this))); | 416 base::Unretained(this))); |
415 | 417 |
416 base::RunLoop().RunUntilIdle(); | 418 base::RunLoop().RunUntilIdle(); |
417 } | 419 } |
OLD | NEW |