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

Side by Side Diff: chrome/browser/task_management/providers/arc/arc_process_task_provider.h

Issue 1523643002: arc-bridge: Move most methods to Mojo interfaces (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Rebased to ToT Created 5 years 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
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_ARC_ARC_PROCESS_TASK_PROVIDER_H _ 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H _
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H _ 6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H _
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "chrome/browser/task_management/providers/arc/arc_process_task.h" 17 #include "chrome/browser/task_management/providers/arc/arc_process_task.h"
17 #include "chrome/browser/task_management/providers/task_provider.h" 18 #include "chrome/browser/task_management/providers/task_provider.h"
18 #include "components/arc/arc_bridge_service.h" 19 #include "components/arc/arc_bridge_service.h"
19 20
20 namespace base { 21 namespace base {
21 class Timer; 22 class Timer;
22 } // namespace base 23 } // namespace base
23 24
24 namespace task_management { 25 namespace task_management {
25 26
26 // This provides the ARC process tasks. 27 // This provides the ARC process tasks.
27 // 28 //
28 // Since this provider obtains ARC process information via IPC and procfs, 29 // Since this provider obtains ARC process information via IPC and procfs,
29 // it can never avoid race conditions. For example, in an extreme case such as 30 // it can never avoid race conditions. For example, in an extreme case such as
30 // fork(2) is called millions of times in a second, this provider can return 31 // fork(2) is called millions of times in a second, this provider can return
31 // wrong results. However, its chance is very low, and even if we hit the case, 32 // wrong results. However, its chance is very low, and even if we hit the case,
32 // the worst outcome is just that an Android app (non-system) process which 33 // the worst outcome is just that an Android app (non-system) process which
33 // the user did not intend to choose is killed. Since Android apps are designed 34 // the user did not intend to choose is killed. Since Android apps are designed
34 // to be killed at any time, it sounds acceptable. 35 // to be killed at any time, it sounds acceptable.
35 class ArcProcessTaskProvider : public TaskProvider, 36 class ArcProcessTaskProvider : public TaskProvider {
36 public arc::ArcBridgeService::ProcessObserver {
37 public: 37 public:
38 ArcProcessTaskProvider(); 38 ArcProcessTaskProvider();
39 ~ArcProcessTaskProvider() override; 39 ~ArcProcessTaskProvider() override;
40 40
41 // task_management::TaskProvider: 41 // task_management::TaskProvider:
42 Task* GetTaskOfUrlRequest(int origin_pid, 42 Task* GetTaskOfUrlRequest(int origin_pid,
43 int child_id, 43 int child_id,
44 int route_id) override; 44 int route_id) override;
45 45
46 // arc::ArcBridgeService::ProcessObserver:
47 void OnUpdateProcessList(
48 const std::vector<arc::RunningAppProcessInfo>& processes) override;
49
50 private: 46 private:
51 void RequestProcessList(); 47 void RequestProcessList();
48 void OnUpdateProcessList(
49 mojo::Array<arc::RunningAppProcessInfoPtr> processes);
52 50
53 void RemoveTasks(const std::set<base::ProcessId>& removed_nspids); 51 void RemoveTasks(const std::set<base::ProcessId>& removed_nspids);
54 void AddTasks(const std::vector<arc::RunningAppProcessInfo>& added_processes, 52 void AddTasks(const std::vector<arc::RunningAppProcessInfo>& added_processes,
55 const std::map<base::ProcessId, base::ProcessId>& nspid_to_pid); 53 const std::map<base::ProcessId, base::ProcessId>& nspid_to_pid);
56 54
57 // task_management::TaskProvider: 55 // task_management::TaskProvider:
58 void StartUpdating() override; 56 void StartUpdating() override;
59 void StopUpdating() override; 57 void StopUpdating() override;
60 58
61 std::map<base::ProcessId, scoped_ptr<ArcProcessTask> > nspid_to_task_; 59 std::map<base::ProcessId, scoped_ptr<ArcProcessTask> > nspid_to_task_;
62 base::RepeatingTimer timer_; 60 base::RepeatingTimer timer_;
63 61
64 // Always keep this the last member of this class to make sure it's the 62 // Always keep this the last member of this class to make sure it's the
65 // first thing to be destructed. 63 // first thing to be destructed.
66 base::WeakPtrFactory<ArcProcessTaskProvider> weak_ptr_factory_; 64 base::WeakPtrFactory<ArcProcessTaskProvider> weak_ptr_factory_;
67 65
68 DISALLOW_COPY_AND_ASSIGN(ArcProcessTaskProvider); 66 DISALLOW_COPY_AND_ASSIGN(ArcProcessTaskProvider);
69 }; 67 };
70 68
71 } // namespace task_management 69 } // namespace task_management
72 70
73 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDE R_H_ 71 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698