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