| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 15 #include "base/native_library.h" | 16 #include "base/native_library.h" |
| 16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 17 #include "base/profiler/native_stack_sampler.h" | 18 #include "base/profiler/native_stack_sampler.h" |
| 18 #include "base/profiler/stack_sampling_profiler.h" | 19 #include "base/profiler/stack_sampling_profiler.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 ::GetLastError() != ERROR_MOD_NOT_FOUND) { | 303 ::GetLastError() != ERROR_MOD_NOT_FOUND) { |
| 303 PlatformThread::Sleep(TimeDelta::FromMilliseconds(1)); | 304 PlatformThread::Sleep(TimeDelta::FromMilliseconds(1)); |
| 304 } | 305 } |
| 305 #else | 306 #else |
| 306 NOTIMPLEMENTED(); | 307 NOTIMPLEMENTED(); |
| 307 #endif | 308 #endif |
| 308 } | 309 } |
| 309 | 310 |
| 310 // Called on the profiler thread when complete, to collect profiles. | 311 // Called on the profiler thread when complete, to collect profiles. |
| 311 void SaveProfiles(CallStackProfiles* profiles, | 312 void SaveProfiles(CallStackProfiles* profiles, |
| 312 const CallStackProfiles& pending_profiles) { | 313 CallStackProfiles pending_profiles) { |
| 313 *profiles = pending_profiles; | 314 *profiles = std::move(pending_profiles); |
| 314 } | 315 } |
| 315 | 316 |
| 316 // Called on the profiler thread when complete. Collects profiles produced by | 317 // Called on the profiler thread when complete. Collects profiles produced by |
| 317 // the profiler, and signals an event to allow the main thread to know that that | 318 // the profiler, and signals an event to allow the main thread to know that that |
| 318 // the profiler is done. | 319 // the profiler is done. |
| 319 void SaveProfilesAndSignalEvent(CallStackProfiles* profiles, | 320 void SaveProfilesAndSignalEvent(CallStackProfiles* profiles, |
| 320 WaitableEvent* event, | 321 WaitableEvent* event, |
| 321 const CallStackProfiles& pending_profiles) { | 322 CallStackProfiles pending_profiles) { |
| 322 *profiles = pending_profiles; | 323 *profiles = std::move(pending_profiles); |
| 323 event->Signal(); | 324 event->Signal(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 // Executes the function with the target thread running and executing within | 327 // Executes the function with the target thread running and executing within |
| 327 // SignalAndWaitUntilSignaled(). Performs all necessary target thread startup | 328 // SignalAndWaitUntilSignaled(). Performs all necessary target thread startup |
| 328 // and shutdown work before and afterward. | 329 // and shutdown work before and afterward. |
| 329 template <class Function> | 330 template <class Function> |
| 330 void WithTargetThread(Function function, | 331 void WithTargetThread(Function function, |
| 331 const StackConfiguration& stack_config) { | 332 const StackConfiguration& stack_config) { |
| 332 TargetThread target_thread(stack_config); | 333 TargetThread target_thread(stack_config); |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 977 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
| 977 #define MAYBE_UnloadedLibrary UnloadedLibrary | 978 #define MAYBE_UnloadedLibrary UnloadedLibrary |
| 978 #else | 979 #else |
| 979 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary | 980 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary |
| 980 #endif | 981 #endif |
| 981 TEST(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { | 982 TEST(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { |
| 982 TestLibraryUnload(true); | 983 TestLibraryUnload(true); |
| 983 } | 984 } |
| 984 | 985 |
| 985 } // namespace base | 986 } // namespace base |
| OLD | NEW |