Chromium Code Reviews| Index: webrtc/voice_engine/statistics.cc |
| diff --git a/webrtc/voice_engine/statistics.cc b/webrtc/voice_engine/statistics.cc |
| index 3787e671224faaaa05b199163fb1fce2a9b9ac53..0d8250fa98a10f66f2fbcc63b218d8c1f234c27c 100644 |
| --- a/webrtc/voice_engine/statistics.cc |
| +++ b/webrtc/voice_engine/statistics.cc |
| @@ -13,7 +13,6 @@ |
| #include "webrtc/voice_engine/statistics.h" |
| -#include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| #include "webrtc/system_wrappers/include/trace.h" |
| namespace webrtc { |
| @@ -21,20 +20,14 @@ namespace webrtc { |
| namespace voe { |
| Statistics::Statistics(uint32_t instanceId) : |
| - _critPtr(CriticalSectionWrapper::CreateCriticalSection()), |
| _instanceId(instanceId), |
| _lastError(0), |
| _isInitialized(false) |
| { |
| } |
| - |
| + |
| Statistics::~Statistics() |
| { |
| - if (_critPtr) |
| - { |
| - delete _critPtr; |
| - _critPtr = NULL; |
| - } |
| } |
| int32_t Statistics::SetInitialized() |
| @@ -56,7 +49,7 @@ bool Statistics::Initialized() const |
| int32_t Statistics::SetLastError(int32_t error) const |
| { |
| - CriticalSectionScoped cs(_critPtr); |
| + rtc::CritScope cs(&lock_); |
| _lastError = error; |
| return 0; |
| } |
| @@ -64,11 +57,11 @@ int32_t Statistics::SetLastError(int32_t error) const |
| int32_t Statistics::SetLastError(int32_t error, |
| TraceLevel level) const |
| { |
| - CriticalSectionScoped cs(_critPtr); |
| - _lastError = error; |
| WEBRTC_TRACE(level, kTraceVoice, VoEId(_instanceId,-1), |
| "error code is set to %d", |
| - _lastError); |
| + error); |
| + rtc::CritScope cs(&lock_); |
|
tommi
2016/01/20 17:34:48
here I also reduced the scope of the lock.
the sun
2016/01/21 13:07:28
Acknowledged.
|
| + _lastError = error; |
| return 0; |
| } |
| @@ -76,22 +69,28 @@ int32_t Statistics::SetLastError( |
| int32_t error, |
| TraceLevel level, const char* msg) const |
| { |
| - CriticalSectionScoped cs(_critPtr); |
| char traceMessage[KTraceMaxMessageSize]; |
| assert(strlen(msg) < KTraceMaxMessageSize); |
| - _lastError = error; |
| sprintf(traceMessage, "%s (error=%d)", msg, error); |
| + |
| WEBRTC_TRACE(level, kTraceVoice, VoEId(_instanceId,-1), "%s", |
| traceMessage); |
| + |
| + rtc::CritScope cs(&lock_); |
|
tommi
2016/01/20 17:34:48
and here too
the sun
2016/01/21 13:07:28
Acknowledged.
|
| + _lastError = error; |
| return 0; |
| } |
| int32_t Statistics::LastError() const |
| { |
| - CriticalSectionScoped cs(_critPtr); |
| - WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId,-1), |
| - "LastError() => %d", _lastError); |
| - return _lastError; |
| + int32_t ret; |
| + { |
| + rtc::CritScope cs(&lock_); |
|
tommi
2016/01/20 17:34:48
and here three...
the sun
2016/01/21 13:07:28
Acknowledged.
|
| + ret = _lastError; |
| + } |
| + WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, VoEId(_instanceId, -1), |
| + "LastError() => %d", ret); |
| + return ret; |
| } |
| } // namespace voe |