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 "webkit/glue/webkitplatformsupport_impl.h" | 5 #include "webkit/glue/webkitplatformsupport_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/allocator/allocator_extension.h" | 11 #include "base/allocator/allocator_extension.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/debug/trace_event.h" | |
14 #include "base/memory/discardable_memory.h" | 13 #include "base/memory/discardable_memory.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
17 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
18 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
19 #include "base/metrics/stats_counters.h" | 18 #include "base/metrics/stats_counters.h" |
20 #include "base/platform_file.h" | 19 #include "base/platform_file.h" |
21 #include "base/process_util.h" | 20 #include "base/process_util.h" |
22 #include "base/rand_util.h" | 21 #include "base/rand_util.h" |
23 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 boundary_value + 1, base::HistogramBase::kUmaTargetedHistogramFlag); | 445 boundary_value + 1, base::HistogramBase::kUmaTargetedHistogramFlag); |
447 DCHECK_EQ(name, counter->histogram_name()); | 446 DCHECK_EQ(name, counter->histogram_name()); |
448 counter->Add(sample); | 447 counter->Add(sample); |
449 } | 448 } |
450 | 449 |
451 const unsigned char* WebKitPlatformSupportImpl::getTraceCategoryEnabledFlag( | 450 const unsigned char* WebKitPlatformSupportImpl::getTraceCategoryEnabledFlag( |
452 const char* category_name) { | 451 const char* category_name) { |
453 return TRACE_EVENT_API_GET_CATEGORY_ENABLED(category_name); | 452 return TRACE_EVENT_API_GET_CATEGORY_ENABLED(category_name); |
454 } | 453 } |
455 | 454 |
455 TRACE_EVENT_API_ATOMIC_WORD* WebKitPlatformSupportImpl::getTraceSamplingState( | |
456 const unsigned thread_bucket) { | |
457 switch(thread_bucket) { | |
abarth-chromium
2013/02/27 02:58:00
Is this really better than a branch + TRACE_EVENT_
haraken
2013/02/27 03:29:55
I cannot use it because it results in 'g_trace_sta
| |
458 case 0: | |
459 return reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD*>( | |
460 &TRACE_EVENT_API_THREAD_BUCKET(0)); | |
461 case 1: | |
462 return reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD*>( | |
463 &TRACE_EVENT_API_THREAD_BUCKET(1)); | |
464 case 2: | |
465 return reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD*>( | |
466 &TRACE_EVENT_API_THREAD_BUCKET(2)); | |
467 default: | |
468 NOTREACHED() << "Unknown thread bucket type."; | |
469 } | |
470 return NULL; | |
471 } | |
472 | |
456 void WebKitPlatformSupportImpl::addTraceEvent( | 473 void WebKitPlatformSupportImpl::addTraceEvent( |
457 char phase, | 474 char phase, |
458 const unsigned char* category_enabled, | 475 const unsigned char* category_enabled, |
459 const char* name, | 476 const char* name, |
460 unsigned long long id, | 477 unsigned long long id, |
461 int num_args, | 478 int num_args, |
462 const char** arg_names, | 479 const char** arg_names, |
463 const unsigned char* arg_types, | 480 const unsigned char* arg_types, |
464 const unsigned long long* arg_values, | 481 const unsigned long long* arg_values, |
465 unsigned char flags) { | 482 unsigned char flags) { |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
952 return NULL; | 969 return NULL; |
953 scoped_ptr<WebDiscardableMemoryImpl> discardable( | 970 scoped_ptr<WebDiscardableMemoryImpl> discardable( |
954 new WebDiscardableMemoryImpl()); | 971 new WebDiscardableMemoryImpl()); |
955 if (discardable->InitializeAndLock(bytes)) | 972 if (discardable->InitializeAndLock(bytes)) |
956 return discardable.release(); | 973 return discardable.release(); |
957 return NULL; | 974 return NULL; |
958 } | 975 } |
959 | 976 |
960 | 977 |
961 } // namespace webkit_glue | 978 } // namespace webkit_glue |
OLD | NEW |