nacl_broker_host_win.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright (c) 2012 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_BROWSER_NACL_BROKER_HOST_WIN_H_
  5. #define COMPONENTS_NACL_BROWSER_NACL_BROKER_HOST_WIN_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include <string>
  9. #include "base/process/process.h"
  10. #include "content/public/browser/browser_child_process_host_delegate.h"
  11. #include "mojo/public/cpp/system/message_pipe.h"
  12. namespace content {
  13. class BrowserChildProcessHost;
  14. }
  15. namespace nacl {
  16. class NaClBrokerHost : public content::BrowserChildProcessHostDelegate {
  17. public:
  18. NaClBrokerHost();
  19. NaClBrokerHost(const NaClBrokerHost&) = delete;
  20. NaClBrokerHost& operator=(const NaClBrokerHost&) = delete;
  21. ~NaClBrokerHost() override;
  22. // This function starts the broker process. It needs to be called
  23. // before loaders can be launched.
  24. bool Init();
  25. // Send a message to the broker process, causing it to launch
  26. // a Native Client loader process.
  27. bool LaunchLoader(int launch_id,
  28. mojo::ScopedMessagePipeHandle ipc_channel_handle);
  29. bool LaunchDebugExceptionHandler(int32_t pid,
  30. base::ProcessHandle process_handle,
  31. const std::string& startup_info);
  32. // Stop the broker process.
  33. void StopBroker();
  34. // Returns true if the process has been asked to terminate. If true, this
  35. // object should no longer be used; it will eventually be destroyed by
  36. // BrowserChildProcessHostImpl::OnChildDisconnected()
  37. bool IsTerminating() { return is_terminating_; }
  38. private:
  39. // Handler for NaClProcessMsg_LoaderLaunched message
  40. void OnLoaderLaunched(int launch_id, base::ProcessHandle handle);
  41. // Handler for NaClProcessMsg_DebugExceptionHandlerLaunched message
  42. void OnDebugExceptionHandlerLaunched(int32_t pid, bool success);
  43. // BrowserChildProcessHostDelegate implementation:
  44. bool OnMessageReceived(const IPC::Message& msg) override;
  45. std::unique_ptr<content::BrowserChildProcessHost> process_;
  46. bool is_terminating_;
  47. };
  48. } // namespace nacl
  49. #endif // COMPONENTS_NACL_BROWSER_NACL_BROKER_HOST_WIN_H_