nacl_broker_listener.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2013 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. #ifndef COMPONENTS_NACL_BROKER_NACL_BROKER_LISTENER_H_
  5. #define COMPONENTS_NACL_BROKER_NACL_BROKER_LISTENER_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include "base/process/process.h"
  9. #include "base/run_loop.h"
  10. #include "components/nacl/common/nacl_types.h"
  11. #include "content/public/common/sandboxed_process_launcher_delegate.h"
  12. #include "ipc/ipc_listener.h"
  13. namespace IPC {
  14. class Channel;
  15. }
  16. // The BrokerThread class represents the thread that handles the messages from
  17. // the browser process and starts NaCl loader processes.
  18. class NaClBrokerListener : public content::SandboxedProcessLauncherDelegate,
  19. public IPC::Listener {
  20. public:
  21. NaClBrokerListener();
  22. NaClBrokerListener(const NaClBrokerListener&) = delete;
  23. NaClBrokerListener& operator=(const NaClBrokerListener&) = delete;
  24. ~NaClBrokerListener() override;
  25. void Listen();
  26. // content::SandboxedProcessLauncherDelegate implementation:
  27. sandbox::mojom::Sandbox GetSandboxType() override;
  28. std::string GetSandboxTag() override;
  29. // IPC::Listener implementation.
  30. void OnChannelConnected(int32_t peer_pid) override;
  31. bool OnMessageReceived(const IPC::Message& msg) override;
  32. void OnChannelError() override;
  33. private:
  34. void OnLaunchLoaderThroughBroker(
  35. int launch_id,
  36. mojo::MessagePipeHandle service_request_pipe);
  37. void OnLaunchDebugExceptionHandler(int32_t pid,
  38. base::ProcessHandle process_handle,
  39. const std::string& startup_info);
  40. void OnStopBroker();
  41. base::RunLoop run_loop_;
  42. base::Process browser_process_;
  43. std::unique_ptr<IPC::Channel> channel_;
  44. };
  45. #endif // COMPONENTS_NACL_BROKER_NACL_BROKER_LISTENER_H_