| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trace_event/trace_log.h" | 5 #include "base/trace_event/trace_log.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 | 825 |
| 826 if (!IsEnabled()) | 826 if (!IsEnabled()) |
| 827 return; | 827 return; |
| 828 | 828 |
| 829 if (dispatching_to_observer_list_) { | 829 if (dispatching_to_observer_list_) { |
| 830 DLOG(ERROR) | 830 DLOG(ERROR) |
| 831 << "Cannot manipulate TraceLog::Enabled state from an observer."; | 831 << "Cannot manipulate TraceLog::Enabled state from an observer."; |
| 832 return; | 832 return; |
| 833 } | 833 } |
| 834 | 834 |
| 835 mode_ = DISABLED; | |
| 836 | |
| 837 if (sampling_thread_) { | 835 if (sampling_thread_) { |
| 838 // Stop the sampling thread. | 836 // Stop the sampling thread. |
| 839 sampling_thread_->Stop(); | 837 sampling_thread_->Stop(); |
| 840 lock_.Release(); | 838 lock_.Release(); |
| 841 PlatformThread::Join(sampling_thread_handle_); | 839 PlatformThread::Join(sampling_thread_handle_); |
| 842 lock_.Acquire(); | 840 lock_.Acquire(); |
| 843 sampling_thread_handle_ = PlatformThreadHandle(); | 841 sampling_thread_handle_ = PlatformThreadHandle(); |
| 844 sampling_thread_.reset(); | 842 sampling_thread_.reset(); |
| 845 } | 843 } |
| 846 | 844 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 858 enabled_state_observer_list_; | 856 enabled_state_observer_list_; |
| 859 std::map<AsyncEnabledStateObserver*, RegisteredAsyncObserver> observer_map = | 857 std::map<AsyncEnabledStateObserver*, RegisteredAsyncObserver> observer_map = |
| 860 async_observers_; | 858 async_observers_; |
| 861 | 859 |
| 862 { | 860 { |
| 863 // Dispatch to observers outside the lock in case the observer triggers a | 861 // Dispatch to observers outside the lock in case the observer triggers a |
| 864 // trace event. | 862 // trace event. |
| 865 AutoUnlock unlock(lock_); | 863 AutoUnlock unlock(lock_); |
| 866 for (EnabledStateObserver* observer : observer_list) | 864 for (EnabledStateObserver* observer : observer_list) |
| 867 observer->OnTraceLogDisabled(); | 865 observer->OnTraceLogDisabled(); |
| 866 mode_ = DISABLED; |
| 868 for (const auto& it : observer_map) { | 867 for (const auto& it : observer_map) { |
| 869 it.second.task_runner->PostTask( | 868 it.second.task_runner->PostTask( |
| 870 FROM_HERE, Bind(&AsyncEnabledStateObserver::OnTraceLogDisabled, | 869 FROM_HERE, Bind(&AsyncEnabledStateObserver::OnTraceLogDisabled, |
| 871 it.second.observer)); | 870 it.second.observer)); |
| 872 } | 871 } |
| 873 } | 872 } |
| 874 dispatching_to_observer_list_ = false; | 873 dispatching_to_observer_list_ = false; |
| 875 } | 874 } |
| 876 | 875 |
| 877 int TraceLog::GetNumTracesRecorded() { | 876 int TraceLog::GetNumTracesRecorded() { |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1921 } | 1920 } |
| 1922 | 1921 |
| 1923 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1922 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1924 if (*category_group_enabled_) { | 1923 if (*category_group_enabled_) { |
| 1925 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1924 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1926 event_handle_); | 1925 event_handle_); |
| 1927 } | 1926 } |
| 1928 } | 1927 } |
| 1929 | 1928 |
| 1930 } // namespace trace_event_internal | 1929 } // namespace trace_event_internal |
| OLD | NEW |