OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/devtools/v8_sampling_profiler.h" | 5 #include "content/renderer/devtools/v8_sampling_profiler.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 9 #include "base/format_macros.h" |
| 10 #include "base/location.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/synchronization/cancellation_flag.h" |
| 14 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/threading/platform_thread.h" |
| 16 #include "base/trace_event/trace_event.h" |
| 17 #include "base/trace_event/trace_event_argument.h" |
| 18 #include "build/build_config.h" |
| 19 #include "content/renderer/devtools/lock_free_circular_queue.h" |
| 20 #include "content/renderer/render_thread_impl.h" |
| 21 #include "v8/include/v8.h" |
| 22 |
7 #if defined(OS_POSIX) | 23 #if defined(OS_POSIX) |
8 #include <signal.h> | 24 #include <signal.h> |
9 #define USE_SIGNALS | 25 #define USE_SIGNALS |
10 #endif | 26 #endif |
11 | 27 |
12 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
13 #include <windows.h> | 29 #include <windows.h> |
14 #endif | 30 #endif |
15 | 31 |
16 #include "base/format_macros.h" | |
17 #include "base/location.h" | |
18 #include "base/strings/stringprintf.h" | |
19 #include "base/synchronization/cancellation_flag.h" | |
20 #include "base/thread_task_runner_handle.h" | |
21 #include "base/threading/platform_thread.h" | |
22 #include "base/trace_event/trace_event.h" | |
23 #include "base/trace_event/trace_event_argument.h" | |
24 #include "content/renderer/devtools/lock_free_circular_queue.h" | |
25 #include "content/renderer/render_thread_impl.h" | |
26 #include "v8/include/v8.h" | |
27 | |
28 using base::trace_event::ConvertableToTraceFormat; | 32 using base::trace_event::ConvertableToTraceFormat; |
29 using base::trace_event::TraceLog; | 33 using base::trace_event::TraceLog; |
30 using base::trace_event::TracedValue; | 34 using base::trace_event::TracedValue; |
31 using v8::Isolate; | 35 using v8::Isolate; |
32 | 36 |
33 namespace content { | 37 namespace content { |
34 | 38 |
35 namespace { | 39 namespace { |
36 | 40 |
37 class PlatformDataCommon { | 41 class PlatformDataCommon { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 84 |
81 HANDLE thread_handle() { return thread_handle_; } | 85 HANDLE thread_handle() { return thread_handle_; } |
82 | 86 |
83 private: | 87 private: |
84 HANDLE thread_handle_; | 88 HANDLE thread_handle_; |
85 }; | 89 }; |
86 #endif | 90 #endif |
87 | 91 |
88 std::string PtrToString(const void* value) { | 92 std::string PtrToString(const void* value) { |
89 return base::StringPrintf( | 93 return base::StringPrintf( |
90 "0x%" PRIx64, static_cast<uint64>(reinterpret_cast<intptr_t>(value))); | 94 "0x%" PRIx64, static_cast<uint64_t>(reinterpret_cast<intptr_t>(value))); |
91 } | 95 } |
92 | 96 |
93 class SampleRecord { | 97 class SampleRecord { |
94 public: | 98 public: |
95 static const int kMaxFramesCountLog2 = 8; | 99 static const int kMaxFramesCountLog2 = 8; |
96 static const unsigned kMaxFramesCount = (1u << kMaxFramesCountLog2) - 1; | 100 static const unsigned kMaxFramesCount = (1u << kMaxFramesCountLog2) - 1; |
97 | 101 |
98 SampleRecord() {} | 102 SampleRecord() {} |
99 | 103 |
100 base::TimeTicks timestamp() const { return timestamp_; } | 104 base::TimeTicks timestamp() const { return timestamp_; } |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 render_thread_sampler_->SetEventsToCollectForTest(code_added_events, | 635 render_thread_sampler_->SetEventsToCollectForTest(code_added_events, |
632 sample_events); | 636 sample_events); |
633 waitable_event_for_testing_.reset(new base::WaitableEvent(false, false)); | 637 waitable_event_for_testing_.reset(new base::WaitableEvent(false, false)); |
634 } | 638 } |
635 | 639 |
636 void V8SamplingProfiler::WaitSamplingEventForTesting() { | 640 void V8SamplingProfiler::WaitSamplingEventForTesting() { |
637 waitable_event_for_testing_->Wait(); | 641 waitable_event_for_testing_->Wait(); |
638 } | 642 } |
639 | 643 |
640 } // namespace content | 644 } // namespace content |
OLD | NEW |