Chromium Code Reviews| Index: chrome/browser/task_manager/providers/task.cc |
| diff --git a/chrome/browser/task_manager/providers/task.cc b/chrome/browser/task_manager/providers/task.cc |
| index a49032f6875cd6612cc2777b5606b34ff56d9356..d1b63ac8665f0f2eed9f753ca9865aebe94818c0 100644 |
| --- a/chrome/browser/task_manager/providers/task.cc |
| +++ b/chrome/browser/task_manager/providers/task.cc |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/profiles/profile_attributes_entry.h" |
| #include "chrome/browser/profiles/profile_attributes_storage.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| +#include "chrome/browser/task_manager/providers/task_provider_observer.h" |
| #include "chrome/browser/task_manager/task_manager_observer.h" |
| #include "content/public/common/result_codes.h" |
| @@ -22,6 +23,13 @@ namespace { |
| // The last ID given to the previously created task. |
| int64_t g_last_id = 0; |
| +base::ProcessId DetermineProcessId(base::ProcessHandle handle, |
| + base::ProcessId process_id) { |
| + if (process_id != base::kNullProcessId) |
| + return process_id; |
| + return base::GetProcId(handle); |
| +} |
| + |
| } // namespace |
| Task::Task(const base::string16& title, |
| @@ -36,9 +44,7 @@ Task::Task(const base::string16& title, |
| rappor_sample_name_(rappor_sample), |
| icon_(icon ? *icon : gfx::ImageSkia()), |
| process_handle_(handle), |
| - process_id_(process_id != base::kNullProcessId |
| - ? process_id |
| - : base::GetProcId(handle)) {} |
| + process_id_(DetermineProcessId(handle, process_id)) {} |
| Task::~Task() {} |
| @@ -83,6 +89,24 @@ void Task::Refresh(const base::TimeDelta& update_interval, |
| current_byte_count_ = 0; |
| } |
| +void Task::UpdateProcessInfo(base::ProcessHandle handle, |
| + base::ProcessId process_id, |
| + TaskProviderObserver* observer) { |
| + process_id = DetermineProcessId(handle, process_id); |
| + |
| + // Don't remove the task if there is no change to the process ID. |
| + if (process_id == process_id_) |
| + return; |
| + |
| + // TaskManagerImpl and TaskGroup implementations assume that a process id is |
|
afakhry
2017/07/10 17:27:53
Nit: process id => ditto.
ncarter (slow)
2017/07/31 22:30:29
Done.
|
| + // consistent for the lifetime of a Task. So to change the process ID, |
| + // temporarily unregister this Task. |
| + observer->TaskRemoved(this); |
| + process_handle_ = handle; |
| + process_id_ = process_id; |
| + observer->TaskAdded(this); |
| +} |
| + |
| void Task::OnNetworkBytesRead(int64_t bytes_read) { |
| if (current_byte_count_ == -1) |
| current_byte_count_ = 0; |