| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // Example: | 27 // Example: |
| 28 // void OnUpdateProcessList(const vector<arc::ArcProcess>&) {...} | 28 // void OnUpdateProcessList(const vector<arc::ArcProcess>&) {...} |
| 29 // | 29 // |
| 30 // arc::ArcProcessService* arc_process_service = | 30 // arc::ArcProcessService* arc_process_service = |
| 31 // arc::ArcProcessService::Get(); | 31 // arc::ArcProcessService::Get(); |
| 32 // if (!arc_process_service || | 32 // if (!arc_process_service || |
| 33 // !arc_process_service->RequestProcessList( | 33 // !arc_process_service->RequestProcessList( |
| 34 // base::Bind(&OnUpdateProcessList)) { | 34 // base::Bind(&OnUpdateProcessList)) { |
| 35 // LOG(ERROR) << "ARC process instance not ready."; | 35 // LOG(ERROR) << "ARC process instance not ready."; |
| 36 // } | 36 // } |
| 37 class ArcProcessService : public ArcService, | 37 class ArcProcessService |
| 38 public ArcBridgeService::Observer { | 38 : public ArcService, |
| 39 public ArcBridgeService::InstanceObserver<mojom::ProcessInstance> { |
| 39 public: | 40 public: |
| 40 using RequestProcessListCallback = | 41 using RequestProcessListCallback = |
| 41 base::Callback<void(const std::vector<ArcProcess>&)>; | 42 base::Callback<void(const std::vector<ArcProcess>&)>; |
| 42 | 43 |
| 43 explicit ArcProcessService(ArcBridgeService* bridge_service); | 44 explicit ArcProcessService(ArcBridgeService* bridge_service); |
| 44 ~ArcProcessService() override; | 45 ~ArcProcessService() override; |
| 45 | 46 |
| 46 // Returns nullptr before the global instance is ready. | 47 // Returns nullptr before the global instance is ready. |
| 47 static ArcProcessService* Get(); | 48 static ArcProcessService* Get(); |
| 48 | 49 |
| 49 // ArcBridgeService::Observer overrides. | 50 // ArcBridgeService::InstanceObserver<mojom::ProcessInstance> overrides. |
| 50 void OnProcessInstanceReady() override; | 51 void OnInstanceReady(mojom::ProcessInstance*, uint32_t version) override; |
| 51 | 52 |
| 52 // Returns true if ARC IPC is ready for process list request, | 53 // Returns true if ARC IPC is ready for process list request, |
| 53 // otherwise false. | 54 // otherwise false. |
| 54 bool RequestProcessList(RequestProcessListCallback callback); | 55 bool RequestProcessList(RequestProcessListCallback callback); |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 void Reset(); | 58 void Reset(); |
| 58 | 59 |
| 59 void OnReceiveProcessList( | 60 void OnReceiveProcessList( |
| 60 const RequestProcessListCallback& callback, | 61 const RequestProcessListCallback& callback, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 87 // Always keep this the last member of this class to make sure it's the | 88 // Always keep this the last member of this class to make sure it's the |
| 88 // first thing to be destructed. | 89 // first thing to be destructed. |
| 89 base::WeakPtrFactory<ArcProcessService> weak_ptr_factory_; | 90 base::WeakPtrFactory<ArcProcessService> weak_ptr_factory_; |
| 90 | 91 |
| 91 DISALLOW_COPY_AND_ASSIGN(ArcProcessService); | 92 DISALLOW_COPY_AND_ASSIGN(ArcProcessService); |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 } // namespace arc | 95 } // namespace arc |
| 95 | 96 |
| 96 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ | 97 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ |
| OLD | NEW |