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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 size_t header_length, | 35 size_t header_length, |
36 size_t packet_length, | 36 size_t packet_length, |
37 bool incoming) override { | 37 bool incoming) override { |
38 current_dump_size_ += header_length; | 38 current_dump_size_ += header_length; |
39 if (current_dump_size_ > max_dump_size_) | 39 if (current_dump_size_ > max_dump_size_) |
40 max_size_reached_callback_.Run(); | 40 max_size_reached_callback_.Run(); |
41 } | 41 } |
42 | 42 |
43 void EndDump(RtpDumpType type, | 43 void EndDump(RtpDumpType type, |
44 const EndDumpCallback& finished_callback) override { | 44 const EndDumpCallback& finished_callback) override { |
45 bool incoming_sucess = end_dump_success_; | 45 bool incoming_success = end_dump_success_; |
46 bool outgoing_success = end_dump_success_; | 46 bool outgoing_success = end_dump_success_; |
47 | 47 |
48 if (type == RTP_DUMP_INCOMING) | 48 if (type == RTP_DUMP_INCOMING) |
49 outgoing_success = false; | 49 outgoing_success = false; |
50 else if (type == RTP_DUMP_OUTGOING) | 50 else if (type == RTP_DUMP_OUTGOING) |
51 incoming_sucess = false; | 51 incoming_success = false; |
52 | 52 |
53 base::ThreadTaskRunnerHandle::Get()->PostTask( | 53 base::ThreadTaskRunnerHandle::Get()->PostTask( |
54 FROM_HERE, | 54 FROM_HERE, |
55 base::Bind(finished_callback, incoming_sucess, outgoing_success)); | 55 base::Bind(finished_callback, incoming_success, outgoing_success)); |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 size_t max_dump_size_; | 59 size_t max_dump_size_; |
60 size_t current_dump_size_; | 60 size_t current_dump_size_; |
61 base::Closure max_size_reached_callback_; | 61 base::Closure max_size_reached_callback_; |
62 bool end_dump_success_; | 62 bool end_dump_success_; |
63 }; | 63 }; |
64 | 64 |
65 class WebRtcRtpDumpHandlerTest : public testing::Test { | 65 class WebRtcRtpDumpHandlerTest : public testing::Test { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler)); | 405 this, &WebRtcRtpDumpHandlerTest::DeleteDumpHandler)); |
406 | 406 |
407 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); | 407 EXPECT_TRUE(handler_->StartDump(RTP_DUMP_BOTH, &error)); |
408 | 408 |
409 handler_->StopOngoingDumps( | 409 handler_->StopOngoingDumps( |
410 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished, | 410 base::Bind(&WebRtcRtpDumpHandlerTest::OnStopOngoingDumpsFinished, |
411 base::Unretained(this))); | 411 base::Unretained(this))); |
412 | 412 |
413 base::RunLoop().RunUntilIdle(); | 413 base::RunLoop().RunUntilIdle(); |
414 } | 414 } |
OLD | NEW |