summaryrefslogtreecommitdiffstats
path: root/chrome/nacl/nacl_main_platform_delegate.h
blob: 540fb958cc69c37e4c83bbb00b874668b05ea316 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_NACL_NACL_MAIN_PLATFORM_DELEGATE_H_
#define CHROME_NACL_NACL_MAIN_PLATFORM_DELEGATE_H_
#pragma once

#include "chrome/common/main_function_params.h"

typedef bool (*RunNaClLoaderTests)(void);
const char kNaClLoaderTestCall[] = "RunNaClLoaderTests";


class NaClMainPlatformDelegate {
 public:
  explicit NaClMainPlatformDelegate(const MainFunctionParams& parameters);
  ~NaClMainPlatformDelegate();

  // Called first thing and last thing in the process' lifecycle, i.e. before
  // the sandbox is enabled.
  void PlatformInitialize();
  void PlatformUninitialize();

  // Gives us an opportunity to initialize state used for tests before enabling
  // the sandbox.
  void InitSandboxTests(bool no_sandbox);

  // Initiate Lockdown, returns true on success.
  bool EnableSandbox();

  // Runs the sandbox tests for the NaCl Loader, if tests supplied.
  // Cannot run again, after this (resources freed).
  void RunSandboxTests();

 private:
  const MainFunctionParams& parameters_;
#if defined(OS_WIN)
  HMODULE sandbox_test_module_;
  // #elif defined(OS_POSIX) doesn't seem to work on Mac.
#elif defined(OS_LINUX) || defined(OS_MACOSX)
  void* sandbox_test_module_;
#endif

  DISALLOW_COPY_AND_ASSIGN(NaClMainPlatformDelegate);
};

#endif  // CHROME_NACL_NACL_MAIN_PLATFORM_DELEGATE_H_