Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3010)

Unified Diff: chrome/browser/task_manager/providers/task.cc

Issue 2961423002: [TaskManager] Allow a Task to mutate its PID after creation (Closed)
Patch Set: Rework comment. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/task_manager/providers/task.h ('k') | chrome/browser/task_manager/providers/task_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a5730fef6ca71ebd4107d6b6774f3df0e7407bfd 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
+ // 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;
« no previous file with comments | « chrome/browser/task_manager/providers/task.h ('k') | chrome/browser/task_manager/providers/task_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698