Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: base/debug/trace_event_impl.cc

Issue 568073003: Use weak_ptr in bind call to TraceLog::OnFlushTimeout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 process_sort_index_(0), 1205 process_sort_index_(0),
1206 process_id_hash_(0), 1206 process_id_hash_(0),
1207 process_id_(0), 1207 process_id_(0),
1208 watch_category_(0), 1208 watch_category_(0),
1209 trace_options_(kInternalRecordUntilFull), 1209 trace_options_(kInternalRecordUntilFull),
1210 sampling_thread_handle_(0), 1210 sampling_thread_handle_(0),
1211 category_filter_(CategoryFilter::kDefaultCategoryFilterString), 1211 category_filter_(CategoryFilter::kDefaultCategoryFilterString),
1212 event_callback_category_filter_( 1212 event_callback_category_filter_(
1213 CategoryFilter::kDefaultCategoryFilterString), 1213 CategoryFilter::kDefaultCategoryFilterString),
1214 thread_shared_chunk_index_(0), 1214 thread_shared_chunk_index_(0),
1215 generation_(0) { 1215 generation_(0),
1216 weak_ptr_factory_(this) {
1216 // Trace is enabled or disabled on one thread while other threads are 1217 // Trace is enabled or disabled on one thread while other threads are
1217 // accessing the enabled flag. We don't care whether edge-case events are 1218 // accessing the enabled flag. We don't care whether edge-case events are
1218 // traced or not, so we allow races on the enabled flag to keep the trace 1219 // traced or not, so we allow races on the enabled flag to keep the trace
1219 // macros fast. 1220 // macros fast.
1220 // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots: 1221 // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots:
1221 // ANNOTATE_BENIGN_RACE_SIZED(g_category_group_enabled, 1222 // ANNOTATE_BENIGN_RACE_SIZED(g_category_group_enabled,
1222 // sizeof(g_category_group_enabled), 1223 // sizeof(g_category_group_enabled),
1223 // "trace_event category enabled"); 1224 // "trace_event category enabled");
1224 for (int i = 0; i < MAX_CATEGORY_GROUPS; ++i) { 1225 for (int i = 0; i < MAX_CATEGORY_GROUPS; ++i) {
1225 ANNOTATE_BENIGN_RACE(&g_category_group_enabled[i], 1226 ANNOTATE_BENIGN_RACE(&g_category_group_enabled[i],
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 } 1721 }
1721 } 1722 }
1722 } 1723 }
1723 1724
1724 if (thread_message_loop_task_runners.size()) { 1725 if (thread_message_loop_task_runners.size()) {
1725 for (size_t i = 0; i < thread_message_loop_task_runners.size(); ++i) { 1726 for (size_t i = 0; i < thread_message_loop_task_runners.size(); ++i) {
1726 thread_message_loop_task_runners[i]->PostTask( 1727 thread_message_loop_task_runners[i]->PostTask(
1727 FROM_HERE, 1728 FROM_HERE,
1728 Bind(&TraceLog::FlushCurrentThread, Unretained(this), generation)); 1729 Bind(&TraceLog::FlushCurrentThread, Unretained(this), generation));
1729 } 1730 }
1730 flush_message_loop_proxy_->PostDelayedTask( 1731 flush_message_loop_proxy_->PostDelayedTask(
mmenke 2014/09/12 17:47:46 The weak pointer factory can only vend weak points
1731 FROM_HERE, 1732 FROM_HERE,
1732 Bind(&TraceLog::OnFlushTimeout, Unretained(this), generation), 1733 Bind(&TraceLog::OnFlushTimeout,
1734 weak_ptr_factory_.GetWeakPtr(),
1735 generation),
1733 TimeDelta::FromMilliseconds(kThreadFlushTimeoutMs)); 1736 TimeDelta::FromMilliseconds(kThreadFlushTimeoutMs));
1734 return; 1737 return;
1735 } 1738 }
1736 1739
1737 FinishFlush(generation); 1740 FinishFlush(generation);
1738 } 1741 }
1739 1742
1740 void TraceLog::ConvertTraceEventsToTraceFormat( 1743 void TraceLog::ConvertTraceEventsToTraceFormat(
1741 scoped_ptr<TraceBuffer> logged_events, 1744 scoped_ptr<TraceBuffer> logged_events,
1742 const TraceLog::OutputCallback& flush_output_callback) { 1745 const TraceLog::OutputCallback& flush_output_callback) {
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 } 2574 }
2572 2575
2573 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2576 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2574 if (*category_group_enabled_) { 2577 if (*category_group_enabled_) {
2575 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2578 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2576 name_, event_handle_); 2579 name_, event_handle_);
2577 } 2580 }
2578 } 2581 }
2579 2582
2580 } // namespace trace_event_internal 2583 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698