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

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

Issue 18338004: Don't use StaticMemorySingletonTraits for TraceLog. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: no need for ManualTestSetUp anymore per scheib Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | base/debug/trace_event_unittest.cc » ('j') | 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/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 18 matching lines...) Expand all
29 #include "base/time/time.h" 29 #include "base/time/time.h"
30 30
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 #include "base/debug/trace_event_win.h" 32 #include "base/debug/trace_event_win.h"
33 #endif 33 #endif
34 34
35 class DeleteTraceLogForTesting { 35 class DeleteTraceLogForTesting {
36 public: 36 public:
37 static void Delete() { 37 static void Delete() {
38 Singleton<base::debug::TraceLog, 38 Singleton<base::debug::TraceLog,
39 StaticMemorySingletonTraits<base::debug::TraceLog> >::OnExit(0); 39 LeakySingletonTraits<base::debug::TraceLog> >::OnExit(0);
40 } 40 }
41 }; 41 };
42 42
43 // Not supported in split-dll build. http://crbug.com/237249 43 // Not supported in split-dll build. http://crbug.com/237249
44 #if !defined(CHROME_SPLIT_DLL) 44 #if !defined(CHROME_SPLIT_DLL)
45 // The thread buckets for the sampling profiler. 45 // The thread buckets for the sampling profiler.
46 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; 46 BASE_EXPORT TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
47 #endif 47 #endif
48 48
49 namespace base { 49 namespace base {
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 notification_ |= notification; 736 notification_ |= notification;
737 } 737 }
738 738
739 void TraceLog::NotificationHelper::SendNotificationIfAny() { 739 void TraceLog::NotificationHelper::SendNotificationIfAny() {
740 if (notification_) 740 if (notification_)
741 callback_copy_.Run(notification_); 741 callback_copy_.Run(notification_);
742 } 742 }
743 743
744 // static 744 // static
745 TraceLog* TraceLog::GetInstance() { 745 TraceLog* TraceLog::GetInstance() {
746 return Singleton<TraceLog, StaticMemorySingletonTraits<TraceLog> >::get(); 746 return Singleton<TraceLog, LeakySingletonTraits<TraceLog> >::get();
747 } 747 }
748 748
749 // static 749 // static
750 // Note, if you add more options here you also need to update: 750 // Note, if you add more options here you also need to update:
751 // content/browser/devtools/devtools_tracing_handler:TraceOptionsFromString 751 // content/browser/devtools/devtools_tracing_handler:TraceOptionsFromString
752 TraceLog::Options TraceLog::TraceOptionsFromString(const std::string& options) { 752 TraceLog::Options TraceLog::TraceOptionsFromString(const std::string& options) {
753 std::vector<std::string> split; 753 std::vector<std::string> split;
754 base::SplitString(options, ',', &split); 754 base::SplitString(options, ',', &split);
755 int ret = 0; 755 int ret = 0;
756 for (std::vector<std::string>::iterator iter = split.begin(); 756 for (std::vector<std::string>::iterator iter = split.begin();
(...skipping 11 matching lines...) Expand all
768 } 768 }
769 if (!(ret & RECORD_UNTIL_FULL) && !(ret & RECORD_CONTINUOUSLY)) 769 if (!(ret & RECORD_UNTIL_FULL) && !(ret & RECORD_CONTINUOUSLY))
770 ret |= RECORD_UNTIL_FULL; // Default when no options are specified. 770 ret |= RECORD_UNTIL_FULL; // Default when no options are specified.
771 771
772 return static_cast<Options>(ret); 772 return static_cast<Options>(ret);
773 } 773 }
774 774
775 TraceLog::TraceLog() 775 TraceLog::TraceLog()
776 : enable_count_(0), 776 : enable_count_(0),
777 num_traces_recorded_(0), 777 num_traces_recorded_(0),
778 event_callback_(NULL),
778 dispatching_to_observer_list_(false), 779 dispatching_to_observer_list_(false),
779 watch_category_(NULL), 780 watch_category_(NULL),
780 trace_options_(RECORD_UNTIL_FULL), 781 trace_options_(RECORD_UNTIL_FULL),
781 sampling_thread_handle_(0), 782 sampling_thread_handle_(0),
782 category_filter_(CategoryFilter::kDefaultCategoryFilterString) { 783 category_filter_(CategoryFilter::kDefaultCategoryFilterString) {
783 // Trace is enabled or disabled on one thread while other threads are 784 // Trace is enabled or disabled on one thread while other threads are
784 // accessing the enabled flag. We don't care whether edge-case events are 785 // accessing the enabled flag. We don't care whether edge-case events are
785 // traced or not, so we allow races on the enabled flag to keep the trace 786 // traced or not, so we allow races on the enabled flag to keep the trace
786 // macros fast. 787 // macros fast.
787 // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots: 788 // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots:
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 1319
1319 void TraceLog::InstallWaitableEventForSamplingTesting( 1320 void TraceLog::InstallWaitableEventForSamplingTesting(
1320 WaitableEvent* waitable_event) { 1321 WaitableEvent* waitable_event) {
1321 sampling_thread_->InstallWaitableEventForSamplingTesting(waitable_event); 1322 sampling_thread_->InstallWaitableEventForSamplingTesting(waitable_event);
1322 } 1323 }
1323 1324
1324 void TraceLog::DeleteForTesting() { 1325 void TraceLog::DeleteForTesting() {
1325 DeleteTraceLogForTesting::Delete(); 1326 DeleteTraceLogForTesting::Delete();
1326 } 1327 }
1327 1328
1328 void TraceLog::Resurrect() {
1329 StaticMemorySingletonTraits<TraceLog>::Resurrect();
1330 }
1331
1332 void TraceLog::SetProcessID(int process_id) { 1329 void TraceLog::SetProcessID(int process_id) {
1333 process_id_ = process_id; 1330 process_id_ = process_id;
1334 // Create a FNV hash from the process ID for XORing. 1331 // Create a FNV hash from the process ID for XORing.
1335 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details. 1332 // See http://isthe.com/chongo/tech/comp/fnv/ for algorithm details.
1336 unsigned long long offset_basis = 14695981039346656037ull; 1333 unsigned long long offset_basis = 14695981039346656037ull;
1337 unsigned long long fnv_prime = 1099511628211ull; 1334 unsigned long long fnv_prime = 1099511628211ull;
1338 unsigned long long pid = static_cast<unsigned long long>(process_id_); 1335 unsigned long long pid = static_cast<unsigned long long>(process_id_);
1339 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; 1336 process_id_hash_ = (offset_basis ^ pid) * fnv_prime;
1340 } 1337 }
1341 1338
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 0, // num_args 1544 0, // num_args
1548 NULL, // arg_names 1545 NULL, // arg_names
1549 NULL, // arg_types 1546 NULL, // arg_types
1550 NULL, // arg_values 1547 NULL, // arg_values
1551 NULL, // convertable values 1548 NULL, // convertable values
1552 TRACE_EVENT_FLAG_NONE); // flags 1549 TRACE_EVENT_FLAG_NONE); // flags
1553 } 1550 }
1554 } 1551 }
1555 1552
1556 } // namespace trace_event_internal 1553 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | base/debug/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698