blob: 06c2c6043977aa016d54cc9d8a5878724ee78457 [file] [log] [blame]
[email protected]ac0a3f02014-04-24 03:34:161// Copyright 2014 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
mostynbdf175a82016-02-08 23:27:205// https://chromium.googlesource.com/chromium/src/+/master/docs/linux_sandbox_ipc.md
[email protected]ac0a3f02014-04-24 03:34:166
Vladimir Levin11a23b12017-09-11 23:13:307#ifndef CONTENT_BROWSER_SANDBOX_IPC_LINUX_H_
8#define CONTENT_BROWSER_SANDBOX_IPC_LINUX_H_
[email protected]ac0a3f02014-04-24 03:34:169
dcheng92ae14142016-04-09 02:52:2410#include <memory>
zoeclifford525974c2017-05-17 20:31:0611#include <string>
[email protected]ac0a3f02014-04-24 03:34:1612#include <vector>
13
[email protected]8feaa672014-04-30 21:57:1014#include "base/files/scoped_file.h"
avib533f5d2015-12-25 03:11:1515#include "base/macros.h"
[email protected]ac0a3f02014-04-24 03:34:1616#include "base/pickle.h"
[email protected]ef0dad53c2014-05-23 11:31:1917#include "base/threading/simple_thread.h"
zoeclifford525974c2017-05-17 20:31:0618#include "content/common/content_export.h"
19#include "third_party/icu/source/common/unicode/uchar.h"
tomhudson55241b62016-05-27 14:03:1820
21class SkString;
[email protected]ac0a3f02014-04-24 03:34:1622
23namespace content {
24
[email protected]ef0dad53c2014-05-23 11:31:1925class SandboxIPCHandler : public base::DelegateSimpleThread::Delegate {
[email protected]ac0a3f02014-04-24 03:34:1626 public:
[email protected]ef0dad53c2014-05-23 11:31:1927 // lifeline_fd: the read end of a pipe which the main thread holds
28 // the other end of.
29 // browser_socket: the browser's end of the sandbox IPC socketpair.
30 SandboxIPCHandler(int lifeline_fd, int browser_socket);
dcheng4c1127472014-10-28 00:01:2031 ~SandboxIPCHandler() override;
[email protected]ac0a3f02014-04-24 03:34:1632
dcheng4c1127472014-10-28 00:01:2033 void Run() override;
[email protected]ac0a3f02014-04-24 03:34:1634
zoeclifford525974c2017-05-17 20:31:0635 class TestObserver {
36 public:
37 virtual void OnGetFallbackFontForChar(UChar32 c,
38 std::string name,
39 int id) = 0;
40 virtual void OnFontOpen(int id) = 0;
41 };
42 CONTENT_EXPORT static void SetObserverForTests(TestObserver* observer);
43
[email protected]ac0a3f02014-04-24 03:34:1644 private:
[email protected]ac0a3f02014-04-24 03:34:1645 int FindOrAddPath(const SkString& path);
46
Vladimir Levin11a23b12017-09-11 23:13:3047 void HandleRequestFromChild(int fd);
[email protected]ac0a3f02014-04-24 03:34:1648
49 void HandleFontMatchRequest(int fd,
brettw05cfd8ddb2015-06-02 07:02:4750 base::PickleIterator iter,
mdempskyf12295a2015-12-09 22:54:4651 const std::vector<base::ScopedFD>& fds);
[email protected]ac0a3f02014-04-24 03:34:1652
53 void HandleFontOpenRequest(int fd,
brettw05cfd8ddb2015-06-02 07:02:4754 base::PickleIterator iter,
mdempskyf12295a2015-12-09 22:54:4655 const std::vector<base::ScopedFD>& fds);
[email protected]ac0a3f02014-04-24 03:34:1656
[email protected]aee791a62014-06-12 03:42:4057 void HandleGetFallbackFontForChar(int fd,
mdempskyf12295a2015-12-09 22:54:4658 base::PickleIterator iter,
59 const std::vector<base::ScopedFD>& fds);
[email protected]ac0a3f02014-04-24 03:34:1660
61 void HandleGetStyleForStrike(int fd,
brettw05cfd8ddb2015-06-02 07:02:4762 base::PickleIterator iter,
mdempskyf12295a2015-12-09 22:54:4663 const std::vector<base::ScopedFD>& fds);
[email protected]ac0a3f02014-04-24 03:34:1664
65 void HandleLocaltime(int fd,
brettw05cfd8ddb2015-06-02 07:02:4766 base::PickleIterator iter,
mdempskyf12295a2015-12-09 22:54:4667 const std::vector<base::ScopedFD>& fds);
[email protected]ac0a3f02014-04-24 03:34:1668
[email protected]ac0a3f02014-04-24 03:34:1669 void HandleMakeSharedMemorySegment(int fd,
brettw05cfd8ddb2015-06-02 07:02:4770 base::PickleIterator iter,
mdempskyf12295a2015-12-09 22:54:4671 const std::vector<base::ScopedFD>& fds);
[email protected]ac0a3f02014-04-24 03:34:1672
73 void HandleMatchWithFallback(int fd,
brettw05cfd8ddb2015-06-02 07:02:4774 base::PickleIterator iter,
mdempskyf12295a2015-12-09 22:54:4675 const std::vector<base::ScopedFD>& fds);
[email protected]ac0a3f02014-04-24 03:34:1676
mdempskyf12295a2015-12-09 22:54:4677 void SendRendererReply(const std::vector<base::ScopedFD>& fds,
brettw05cfd8ddb2015-06-02 07:02:4778 const base::Pickle& reply,
[email protected]ac0a3f02014-04-24 03:34:1679 int reply_fd);
80
[email protected]972a99952014-05-01 20:41:2281 const int lifeline_fd_;
[email protected]ac0a3f02014-04-24 03:34:1682 const int browser_socket_;
bungemane27534c22016-02-18 15:58:3883 std::vector<SkString> paths_;
[email protected]ac0a3f02014-04-24 03:34:1684
[email protected]ef0dad53c2014-05-23 11:31:1985 DISALLOW_COPY_AND_ASSIGN(SandboxIPCHandler);
[email protected]ac0a3f02014-04-24 03:34:1686};
87
88} // namespace content
89
tfarinabccc34c72015-02-27 21:32:1590#endif // CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_LINUX_H_