OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/task_manager/sampling/shared_sampler.h" | 5 #include "chrome/browser/task_manager/sampling/shared_sampler.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <winternl.h> | 8 #include <winternl.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 if (!QuerySystemProcessInformation(&data_buffer)) | 392 if (!QuerySystemProcessInformation(&data_buffer)) |
393 return std::unique_ptr<ProcessDataSnapshot>(); | 393 return std::unique_ptr<ProcessDataSnapshot>(); |
394 | 394 |
395 previous_buffer_size_ = data_buffer.capacity(); | 395 previous_buffer_size_ = data_buffer.capacity(); |
396 | 396 |
397 std::unique_ptr<ProcessDataSnapshot> snapshot(new ProcessDataSnapshot); | 397 std::unique_ptr<ProcessDataSnapshot> snapshot(new ProcessDataSnapshot); |
398 snapshot->timestamp = base::TimeTicks::Now(); | 398 snapshot->timestamp = base::TimeTicks::Now(); |
399 | 399 |
400 for (size_t offset = 0; offset < data_buffer.size(); ) { | 400 for (size_t offset = 0; offset < data_buffer.size(); ) { |
401 auto pi = reinterpret_cast<const SYSTEM_PROCESS_INFORMATION*>( | 401 const auto* pi = reinterpret_cast<const SYSTEM_PROCESS_INFORMATION*>( |
402 data_buffer.data() + offset); | 402 data_buffer.data() + offset); |
403 | 403 |
404 // Validate that the offset is valid and all needed data is within | 404 // Validate that the offset is valid and all needed data is within |
405 // the buffer boundary. | 405 // the buffer boundary. |
406 if (offset + sizeof(SYSTEM_PROCESS_INFORMATION) > data_buffer.size()) | 406 if (offset + sizeof(SYSTEM_PROCESS_INFORMATION) > data_buffer.size()) |
407 break; | 407 break; |
408 if (pi->NumberOfThreads > 0 && | 408 if (pi->NumberOfThreads > 0 && |
409 (offset + sizeof(SYSTEM_PROCESS_INFORMATION) + | 409 (offset + sizeof(SYSTEM_PROCESS_INFORMATION) + |
410 (pi->NumberOfThreads - 1) * sizeof(SYSTEM_THREAD_INFORMATION) > | 410 (pi->NumberOfThreads - 1) * sizeof(SYSTEM_THREAD_INFORMATION) > |
411 data_buffer.size())) { | 411 data_buffer.size())) { |
412 break; | 412 break; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 callback_entry.second.on_cpu_time.Run(cpu_time); | 600 callback_entry.second.on_cpu_time.Run(cpu_time); |
601 } | 601 } |
602 } | 602 } |
603 | 603 |
604 // Reset refresh_results_ to trigger RefreshOnWorkerThread next time Refresh | 604 // Reset refresh_results_ to trigger RefreshOnWorkerThread next time Refresh |
605 // is called. | 605 // is called. |
606 refresh_flags_ = 0; | 606 refresh_flags_ = 0; |
607 } | 607 } |
608 | 608 |
609 } // namespace task_manager | 609 } // namespace task_manager |
OLD | NEW |