OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 void HandleEvent(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 98 void HandleEvent(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
99 // Writes the event to the file. Note that this will destroy the state of the | 99 // Writes the event to the file. Note that this will destroy the state of the |
100 // input argument. | 100 // input argument. |
101 void StoreToFile(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 101 void StoreToFile(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
102 // Adds the event to the list of recent events, and removes any events that | 102 // Adds the event to the list of recent events, and removes any events that |
103 // are too old and no longer fall in the time window. | 103 // are too old and no longer fall in the time window. |
104 void AddRecentEvent(const rtclog::Event& event) | 104 void AddRecentEvent(const rtclog::Event& event) |
105 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 105 EXCLUSIVE_LOCKS_REQUIRED(crit_); |
106 | 106 |
107 rtc::CriticalSection crit_; | 107 rtc::CriticalSection crit_; |
108 rtc::scoped_ptr<FileWrapper> file_ GUARDED_BY(crit_) = | 108 std::unique_ptr<FileWrapper> file_ GUARDED_BY(crit_) = |
109 rtc::scoped_ptr<FileWrapper>(FileWrapper::Create()); | 109 std::unique_ptr<FileWrapper>(FileWrapper::Create()); |
the sun
2016/03/12 11:51:13
Is make_unique() C++14 or C++17?
kwiberg-webrtc
2016/03/12 14:06:46
C++14. Although it wouldn't be of any use here, wo
kwiberg-webrtc
2016/03/12 14:10:05
No, auto can’t be used here. This is a class defin
| |
110 rtc::PlatformFile platform_file_ GUARDED_BY(crit_) = | 110 rtc::PlatformFile platform_file_ GUARDED_BY(crit_) = |
111 rtc::kInvalidPlatformFileValue; | 111 rtc::kInvalidPlatformFileValue; |
112 rtclog::EventStream stream_ GUARDED_BY(crit_); | 112 rtclog::EventStream stream_ GUARDED_BY(crit_); |
113 std::deque<rtclog::Event> recent_log_events_ GUARDED_BY(crit_); | 113 std::deque<rtclog::Event> recent_log_events_ GUARDED_BY(crit_); |
114 std::vector<rtclog::Event> config_events_ GUARDED_BY(crit_); | 114 std::vector<rtclog::Event> config_events_ GUARDED_BY(crit_); |
115 | 115 |
116 // Microseconds to record log events, before starting the actual log. | 116 // Microseconds to record log events, before starting the actual log. |
117 int64_t buffer_duration_us_ GUARDED_BY(crit_); | 117 int64_t buffer_duration_us_ GUARDED_BY(crit_); |
118 bool currently_logging_ GUARDED_BY(crit_); | 118 bool currently_logging_ GUARDED_BY(crit_); |
119 int64_t start_time_us_ GUARDED_BY(crit_); | 119 int64_t start_time_us_ GUARDED_BY(crit_); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 rtclog::Event_EventType event_type = event.type(); | 166 rtclog::Event_EventType event_type = event.type(); |
167 return event_type == rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT || | 167 return event_type == rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT || |
168 event_type == rtclog::Event::VIDEO_SENDER_CONFIG_EVENT || | 168 event_type == rtclog::Event::VIDEO_SENDER_CONFIG_EVENT || |
169 event_type == rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT || | 169 event_type == rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT || |
170 event_type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT; | 170 event_type == rtclog::Event::AUDIO_SENDER_CONFIG_EVENT; |
171 } | 171 } |
172 } // namespace | 172 } // namespace |
173 | 173 |
174 // RtcEventLogImpl member functions. | 174 // RtcEventLogImpl member functions. |
175 RtcEventLogImpl::RtcEventLogImpl() | 175 RtcEventLogImpl::RtcEventLogImpl() |
176 : file_(FileWrapper::Create()), | 176 : file_(FileWrapper::Create()), |
stefan-webrtc
2016/03/12 12:05:18
You may not have the answer, but it seems odd to m
kwiberg-webrtc
2016/03/12 14:06:46
I don’t want to do it in this CL. It’s the Unix ph
stefan-webrtc
2016/03/12 14:42:39
Sure, no problem. I was just surprised when I revi
| |
177 stream_(), | 177 stream_(), |
178 buffer_duration_us_(10000000), | 178 buffer_duration_us_(10000000), |
179 currently_logging_(false), | 179 currently_logging_(false), |
180 start_time_us_(0), | 180 start_time_us_(0), |
181 duration_us_(0), | 181 duration_us_(0), |
182 clock_(Clock::GetRealTimeClock()) { | 182 clock_(Clock::GetRealTimeClock()) { |
183 } | 183 } |
184 | 184 |
185 void RtcEventLogImpl::SetBufferDuration(int64_t buffer_duration_us) { | 185 void RtcEventLogImpl::SetBufferDuration(int64_t buffer_duration_us) { |
186 rtc::CritScope lock(&crit_); | 186 rtc::CritScope lock(&crit_); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 config_events_.push_back(recent_log_events_.front()); | 494 config_events_.push_back(recent_log_events_.front()); |
495 } | 495 } |
496 recent_log_events_.pop_front(); | 496 recent_log_events_.pop_front(); |
497 } | 497 } |
498 } | 498 } |
499 | 499 |
500 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, | 500 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, |
501 rtclog::EventStream* result) { | 501 rtclog::EventStream* result) { |
502 char tmp_buffer[1024]; | 502 char tmp_buffer[1024]; |
503 int bytes_read = 0; | 503 int bytes_read = 0; |
504 rtc::scoped_ptr<FileWrapper> dump_file(FileWrapper::Create()); | 504 std::unique_ptr<FileWrapper> dump_file(FileWrapper::Create()); |
505 if (dump_file->OpenFile(file_name.c_str(), true) != 0) { | 505 if (dump_file->OpenFile(file_name.c_str(), true) != 0) { |
506 return false; | 506 return false; |
507 } | 507 } |
508 std::string dump_buffer; | 508 std::string dump_buffer; |
509 while ((bytes_read = dump_file->Read(tmp_buffer, sizeof(tmp_buffer))) > 0) { | 509 while ((bytes_read = dump_file->Read(tmp_buffer, sizeof(tmp_buffer))) > 0) { |
510 dump_buffer.append(tmp_buffer, bytes_read); | 510 dump_buffer.append(tmp_buffer, bytes_read); |
511 } | 511 } |
512 dump_file->CloseFile(); | 512 dump_file->CloseFile(); |
513 return result->ParseFromString(dump_buffer); | 513 return result->ParseFromString(dump_buffer); |
514 } | 514 } |
515 | 515 |
516 #endif // ENABLE_RTC_EVENT_LOG | 516 #endif // ENABLE_RTC_EVENT_LOG |
517 | 517 |
518 // RtcEventLog member functions. | 518 // RtcEventLog member functions. |
519 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { | 519 std::unique_ptr<RtcEventLog> RtcEventLog::Create() { |
520 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); | 520 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); |
521 } | 521 } |
522 | 522 |
523 } // namespace webrtc | 523 } // namespace webrtc |
OLD | NEW |