OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/debug/trace_event_impl.h" | 5 #include "base/debug/trace_event_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 | 1526 |
1527 if (!IsEnabled()) | 1527 if (!IsEnabled()) |
1528 return; | 1528 return; |
1529 | 1529 |
1530 if (dispatching_to_observer_list_) { | 1530 if (dispatching_to_observer_list_) { |
1531 DLOG(ERROR) | 1531 DLOG(ERROR) |
1532 << "Cannot manipulate TraceLog::Enabled state from an observer."; | 1532 << "Cannot manipulate TraceLog::Enabled state from an observer."; |
1533 return; | 1533 return; |
1534 } | 1534 } |
1535 | 1535 |
| 1536 dispatching_to_observer_list_ = true; |
| 1537 std::vector<EnabledStateObserver*> observer_list = |
| 1538 enabled_state_observer_list_; |
| 1539 |
| 1540 { |
| 1541 // Dispatch to observers outside the lock in case the observer triggers a |
| 1542 // trace event. |
| 1543 AutoUnlock unlock(lock_); |
| 1544 for (size_t i = 0; i < observer_list.size(); ++i) |
| 1545 observer_list[i]->OnBeforeTraceLogDisabled(); |
| 1546 } |
| 1547 dispatching_to_observer_list_ = false; |
| 1548 |
1536 mode_ = DISABLED; | 1549 mode_ = DISABLED; |
1537 | 1550 |
1538 if (sampling_thread_.get()) { | 1551 if (sampling_thread_.get()) { |
1539 // Stop the sampling thread. | 1552 // Stop the sampling thread. |
1540 sampling_thread_->Stop(); | 1553 sampling_thread_->Stop(); |
1541 lock_.Release(); | 1554 lock_.Release(); |
1542 PlatformThread::Join(sampling_thread_handle_); | 1555 PlatformThread::Join(sampling_thread_handle_); |
1543 lock_.Acquire(); | 1556 lock_.Acquire(); |
1544 sampling_thread_handle_ = PlatformThreadHandle(); | 1557 sampling_thread_handle_ = PlatformThreadHandle(); |
1545 sampling_thread_.reset(); | 1558 sampling_thread_.reset(); |
1546 } | 1559 } |
1547 | 1560 |
1548 category_filter_.Clear(); | 1561 category_filter_.Clear(); |
1549 subtle::NoBarrier_Store(&watch_category_, 0); | 1562 subtle::NoBarrier_Store(&watch_category_, 0); |
1550 watch_event_name_ = ""; | 1563 watch_event_name_ = ""; |
1551 UpdateCategoryGroupEnabledFlags(); | 1564 UpdateCategoryGroupEnabledFlags(); |
1552 AddMetadataEventsWhileLocked(); | 1565 AddMetadataEventsWhileLocked(); |
1553 | 1566 |
1554 dispatching_to_observer_list_ = true; | 1567 dispatching_to_observer_list_ = true; |
1555 std::vector<EnabledStateObserver*> observer_list = | |
1556 enabled_state_observer_list_; | |
1557 | |
1558 { | 1568 { |
1559 // Dispatch to observers outside the lock in case the observer triggers a | 1569 // Dispatch to observers outside the lock in case the observer triggers a |
1560 // trace event. | 1570 // trace event. |
1561 AutoUnlock unlock(lock_); | 1571 AutoUnlock unlock(lock_); |
1562 for (size_t i = 0; i < observer_list.size(); ++i) | 1572 for (size_t i = 0; i < observer_list.size(); ++i) |
1563 observer_list[i]->OnTraceLogDisabled(); | 1573 observer_list[i]->OnTraceLogDisabled(); |
1564 } | 1574 } |
1565 dispatching_to_observer_list_ = false; | 1575 dispatching_to_observer_list_ = false; |
1566 } | 1576 } |
1567 | 1577 |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 } | 2572 } |
2563 | 2573 |
2564 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2574 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
2565 if (*category_group_enabled_) { | 2575 if (*category_group_enabled_) { |
2566 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2576 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
2567 name_, event_handle_); | 2577 name_, event_handle_); |
2568 } | 2578 } |
2569 } | 2579 } |
2570 | 2580 |
2571 } // namespace trace_event_internal | 2581 } // namespace trace_event_internal |
OLD | NEW |