1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_CHROME_CLEANER_ENGINES_TARGET_ENGINE_COMMANDS_IMPL_H_ 6 #define CHROME_CHROME_CLEANER_ENGINES_TARGET_ENGINE_COMMANDS_IMPL_H_ 7 8 #include <stdint.h> 9 #include <vector> 10 11 #include "base/callback.h" 12 #include "base/memory/ref_counted.h" 13 #include "base/single_thread_task_runner.h" 14 #include "chrome/chrome_cleaner/engines/target/engine_delegate.h" 15 #include "chrome/chrome_cleaner/mojom/cleaner_engine_requests.mojom.h" 16 #include "chrome/chrome_cleaner/mojom/engine_requests.mojom.h" 17 #include "chrome/chrome_cleaner/mojom/engine_sandbox.mojom.h" 18 #include "chrome/chrome_cleaner/pup_data/pup_data.h" 19 #include "mojo/public/cpp/bindings/pending_associated_remote.h" 20 #include "mojo/public/cpp/bindings/pending_receiver.h" 21 #include "mojo/public/cpp/bindings/receiver.h" 22 23 namespace chrome_cleaner { 24 25 class EngineCommandsImpl : public mojom::EngineCommands { 26 public: 27 EngineCommandsImpl(scoped_refptr<EngineDelegate> engine_delegate, 28 mojo::PendingReceiver<mojom::EngineCommands> receiver, 29 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 30 base::OnceClosure error_handler); 31 ~EngineCommandsImpl() override; 32 33 // mojom::EngineCommands 34 35 void Initialize( 36 mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests, 37 const base::FilePath& log_directory, 38 InitializeCallback callback) override; 39 void StartScan( 40 const std::vector<UwSId>& enabled_uws, 41 const std::vector<UwS::TraceLocation>& enabled_trace_locations, 42 bool include_details, 43 mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests, 44 mojo::PendingAssociatedRemote<mojom::EngineRequests> 45 sandboxed_engine_requests, 46 mojo::PendingAssociatedRemote<mojom::EngineScanResults> scan_results, 47 StartScanCallback callback) override; 48 void StartCleanup( 49 const std::vector<UwSId>& enabled_uws, 50 mojo::PendingAssociatedRemote<mojom::EngineFileRequests> file_requests, 51 mojo::PendingAssociatedRemote<mojom::EngineRequests> 52 sandboxed_engine_requests, 53 mojo::PendingAssociatedRemote<mojom::CleanerEngineRequests> 54 sandboxed_cleaner_engine_requests, 55 mojo::PendingAssociatedRemote<mojom::EngineCleanupResults> 56 cleanup_results, 57 StartCleanupCallback callback) override; 58 void Finalize(FinalizeCallback callback) override; 59 60 private: 61 // Invokes |callback(result_code)| on the sequence of |task_runner_|. 62 void PostInitializeCallback( 63 mojom::EngineCommands::InitializeCallback callback, 64 uint32_t result_code); 65 66 scoped_refptr<EngineDelegate> engine_delegate_; 67 mojo::Receiver<mojom::EngineCommands> receiver_; 68 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 69 }; 70 71 } // namespace chrome_cleaner 72 73 #endif // CHROME_CHROME_CLEANER_ENGINES_TARGET_ENGINE_COMMANDS_IMPL_H_ 74