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

Side by Side Diff: chrome/browser/task_management/providers/child_process_task_provider.h

Issue 2183023005: TaskManager: unique_ptr<> ownership of TaskGroups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tm_default_selection
Patch Set: TaskManager: use containers of unique_ptrs instead of stl_util.h Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/task_management/providers/child_process_task_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_CHILD_PROCESS_TASK_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_CHILD_PROCESS_TASK_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_CHILD_PROCESS_TASK_PROVIDER_H_ 6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_CHILD_PROCESS_TASK_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // Creates a ChildProcessTask from the given |data| and notifies the observer 59 // Creates a ChildProcessTask from the given |data| and notifies the observer
60 // of its addition. 60 // of its addition.
61 void CreateTask(const content::ChildProcessData& data); 61 void CreateTask(const content::ChildProcessData& data);
62 62
63 // Deletes a ChildProcessTask whose |handle| is provided after notifying the 63 // Deletes a ChildProcessTask whose |handle| is provided after notifying the
64 // observer of its deletion. 64 // observer of its deletion.
65 void DeleteTask(base::ProcessHandle handle); 65 void DeleteTask(base::ProcessHandle handle);
66 66
67 // A map to track ChildProcessTask's by their handles. 67 // A map to track ChildProcessTask's by their handles.
68 using HandleToTaskMap = std::map<base::ProcessHandle, ChildProcessTask*>; 68 std::map<base::ProcessHandle, std::unique_ptr<ChildProcessTask>>
69 HandleToTaskMap tasks_by_handle_; 69 tasks_by_handle_;
70 70
71 // A map to track ChildProcessTask's by their PIDs. 71 // A map to track ChildProcessTask's by their PIDs.
72 // 72 //
73 // Why have both |tasks_by_handle_| and |tasks_by_pid_|? On Windows, where 73 // Why have both |tasks_by_handle_| and |tasks_by_pid_|? On Windows, where
74 // handles are not the same as PIDs, |DeleteTask| gets only a handle, which 74 // handles are not the same as PIDs, |DeleteTask| gets only a handle, which
75 // may be closed, making it impossible to query the PID from the handle. So 75 // may be closed, making it impossible to query the PID from the handle. So
76 // we need an index on the handle. Meanwhile, we also need an index on the 76 // we need an index on the handle. Meanwhile, we also need an index on the
77 // PID so that we can efficiently implement |GetTaskOfUrlRequest()|, which 77 // PID so that we can efficiently implement |GetTaskOfUrlRequest()|, which
78 // gets only a PID. 78 // gets only a PID.
79 // 79 //
80 // TODO(afakhry): Fix this either by keeping the handle open via 80 // TODO(afakhry): Fix this either by keeping the handle open via
81 // |base::Process|, or amending the |BrowserChildProcessObserver| interface to 81 // |base::Process|, or amending the |BrowserChildProcessObserver| interface to
82 // supply the PID. 82 // supply the PID.
83 using PidToTaskMap = std::map<base::ProcessId, ChildProcessTask*>; 83 std::map<base::ProcessId, ChildProcessTask*> tasks_by_pid_;
84 PidToTaskMap tasks_by_pid_;
85 84
86 // Always keep this the last member of this class to make sure it's the 85 // Always keep this the last member of this class to make sure it's the
87 // first thing to be destructed. 86 // first thing to be destructed.
88 base::WeakPtrFactory<ChildProcessTaskProvider> weak_ptr_factory_; 87 base::WeakPtrFactory<ChildProcessTaskProvider> weak_ptr_factory_;
89 88
90 DISALLOW_COPY_AND_ASSIGN(ChildProcessTaskProvider); 89 DISALLOW_COPY_AND_ASSIGN(ChildProcessTaskProvider);
91 }; 90 };
92 91
93 } // namespace task_management 92 } // namespace task_management
94 93
95 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_CHILD_PROCESS_TASK_PROVIDER_ H_ 94 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_CHILD_PROCESS_TASK_PROVIDER_ H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/task_management/providers/child_process_task_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698