| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 return; | 349 return; |
| 350 | 350 |
| 351 callbacks_map_.erase(process_id); | 351 callbacks_map_.erase(process_id); |
| 352 | 352 |
| 353 if (callbacks_map_.empty()) | 353 if (callbacks_map_.empty()) |
| 354 ClearState(); | 354 ClearState(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void SharedSampler::Refresh(base::ProcessId process_id, int64_t refresh_flags) { | 357 void SharedSampler::Refresh(base::ProcessId process_id, int64_t refresh_flags) { |
| 358 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 358 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 359 DCHECK(callbacks_map_.find(process_id) != callbacks_map_.end()); | |
| 360 DCHECK_NE(0, refresh_flags & GetSupportedFlags()); | 359 DCHECK_NE(0, refresh_flags & GetSupportedFlags()); |
| 361 | 360 |
| 362 if (process_id == 0) | 361 if (process_id == 0) |
| 363 return; | 362 return; |
| 364 | 363 |
| 364 DCHECK(callbacks_map_.find(process_id) != callbacks_map_.end()); |
| 365 |
| 365 if (refresh_flags_ == 0) { | 366 if (refresh_flags_ == 0) { |
| 366 base::PostTaskAndReplyWithResult( | 367 base::PostTaskAndReplyWithResult( |
| 367 blocking_pool_runner_.get(), FROM_HERE, | 368 blocking_pool_runner_.get(), FROM_HERE, |
| 368 base::Bind(&SharedSampler::RefreshOnWorkerThread, this), | 369 base::Bind(&SharedSampler::RefreshOnWorkerThread, this), |
| 369 base::Bind(&SharedSampler::OnRefreshDone, this)); | 370 base::Bind(&SharedSampler::OnRefreshDone, this)); |
| 370 } else { | 371 } else { |
| 371 // A group of consecutive Refresh calls should all specify the same refresh | 372 // A group of consecutive Refresh calls should all specify the same refresh |
| 372 // flags. | 373 // flags. |
| 373 DCHECK_EQ(refresh_flags, refresh_flags_); | 374 DCHECK_EQ(refresh_flags, refresh_flags_); |
| 374 } | 375 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 callback_entry.second.on_physical_memory.Run(physical_bytes); | 628 callback_entry.second.on_physical_memory.Run(physical_bytes); |
| 628 } | 629 } |
| 629 } | 630 } |
| 630 | 631 |
| 631 // Reset refresh_results_ to trigger RefreshOnWorkerThread next time Refresh | 632 // Reset refresh_results_ to trigger RefreshOnWorkerThread next time Refresh |
| 632 // is called. | 633 // is called. |
| 633 refresh_flags_ = 0; | 634 refresh_flags_ = 0; |
| 634 } | 635 } |
| 635 | 636 |
| 636 } // namespace task_manager | 637 } // namespace task_manager |
| OLD | NEW |