OLD | NEW |
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_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_H_ |
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_H_ | 6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "chrome/browser/task_management/providers/task.h" | 14 #include "chrome/browser/task_management/providers/task.h" |
15 #include "components/arc/arc_bridge_service.h" | 15 #include "components/arc/arc_bridge_service.h" |
16 #include "components/arc/common/process.mojom.h" | 16 #include "components/arc/common/process.mojom.h" |
| 17 #include "components/arc/instance_holder.h" |
17 #include "components/arc/intent_helper/activity_icon_loader.h" | 18 #include "components/arc/intent_helper/activity_icon_loader.h" |
18 | 19 |
19 namespace task_management { | 20 namespace task_management { |
20 | 21 |
21 // Defines a task that represents an ARC process. | 22 // Defines a task that represents an ARC process. |
22 class ArcProcessTask : public Task, public arc::ArcBridgeService::Observer { | 23 class ArcProcessTask |
| 24 : public Task, |
| 25 public arc::InstanceHolder<arc::mojom::IntentHelperInstance>::Observer { |
23 public: | 26 public: |
24 ArcProcessTask(base::ProcessId pid, | 27 ArcProcessTask(base::ProcessId pid, |
25 base::ProcessId nspid, | 28 base::ProcessId nspid, |
26 const std::string& process_name, | 29 const std::string& process_name, |
27 arc::mojom::ProcessState process_state, | 30 arc::mojom::ProcessState process_state, |
28 const std::vector<std::string>& packages); | 31 const std::vector<std::string>& packages); |
29 ~ArcProcessTask() override; | 32 ~ArcProcessTask() override; |
30 | 33 |
31 // task_management::Task: | 34 // task_management::Task: |
32 Type GetType() const override; | 35 Type GetType() const override; |
33 int GetChildProcessUniqueID() const override; | 36 int GetChildProcessUniqueID() const override; |
34 bool IsKillable() override; | 37 bool IsKillable() override; |
35 void Kill() override; | 38 void Kill() override; |
36 | 39 |
37 // arc::ArcBridgeService::Observer: | 40 // arc::InstanceHolder<arc::mojom::IntentHelperInstance>::Observer: |
38 void OnIntentHelperInstanceReady() override; | 41 void OnInstanceReady() override; |
39 | 42 |
40 void SetProcessState(arc::mojom::ProcessState process_state); | 43 void SetProcessState(arc::mojom::ProcessState process_state); |
41 | 44 |
42 base::ProcessId nspid() const { return nspid_; } | 45 base::ProcessId nspid() const { return nspid_; } |
43 const std::string& process_name() const { return process_name_; } | 46 const std::string& process_name() const { return process_name_; } |
44 | 47 |
45 private: | 48 private: |
46 void StartIconLoading(); | 49 void StartIconLoading(); |
47 void OnIconLoaded( | 50 void OnIconLoaded( |
48 std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons); | 51 std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons); |
49 | 52 |
50 const base::ProcessId nspid_; | 53 const base::ProcessId nspid_; |
51 const std::string process_name_; | 54 const std::string process_name_; |
52 arc::mojom::ProcessState process_state_; | 55 arc::mojom::ProcessState process_state_; |
53 const std::string package_name_; | 56 const std::string package_name_; |
54 | 57 |
55 // Note: This should remain the last member so it'll be destroyed and | 58 // Note: This should remain the last member so it'll be destroyed and |
56 // invalidate the weak pointers before any other members are destroyed. | 59 // invalidate the weak pointers before any other members are destroyed. |
57 base::WeakPtrFactory<ArcProcessTask> weak_ptr_factory_; | 60 base::WeakPtrFactory<ArcProcessTask> weak_ptr_factory_; |
58 | 61 |
59 DISALLOW_COPY_AND_ASSIGN(ArcProcessTask); | 62 DISALLOW_COPY_AND_ASSIGN(ArcProcessTask); |
60 }; | 63 }; |
61 | 64 |
62 } // namespace task_management | 65 } // namespace task_management |
63 | 66 |
64 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_H_ | 67 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_H_ |
OLD | NEW |