OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/render_sandbox_host_linux.h" | 5 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <fontconfig/fontconfig.h> | 8 #include <fontconfig/fontconfig.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "base/string_util.h" | 29 #include "base/string_util.h" |
30 #include "content/common/font_config_ipc_linux.h" | 30 #include "content/common/font_config_ipc_linux.h" |
31 #include "content/common/sandbox_linux.h" | 31 #include "content/common/sandbox_linux.h" |
32 #include "content/common/webkitplatformsupport_impl.h" | 32 #include "content/common/webkitplatformsupport_impl.h" |
33 #include "skia/ext/SkFontHost_fontconfig_direct.h" | 33 #include "skia/ext/SkFontHost_fontconfig_direct.h" |
34 #include "third_party/npapi/bindings/npapi_extensions.h" | 34 #include "third_party/npapi/bindings/npapi_extensions.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontInfo.h" |
37 #include "ui/gfx/font_render_params_linux.h" | 37 #include "ui/gfx/font_render_params_linux.h" |
38 | 38 |
39 using content::LinuxSandbox; | |
40 using WebKit::WebCString; | 39 using WebKit::WebCString; |
41 using WebKit::WebFontInfo; | 40 using WebKit::WebFontInfo; |
42 using WebKit::WebUChar; | 41 using WebKit::WebUChar; |
43 | 42 |
| 43 namespace content { |
| 44 |
44 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC | 45 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC |
45 | 46 |
46 // BEWARE: code in this file run across *processes* (not just threads). | 47 // BEWARE: code in this file run across *processes* (not just threads). |
47 | 48 |
48 // This code runs in a child process | 49 // This code runs in a child process |
49 class SandboxIPCProcess { | 50 class SandboxIPCProcess { |
50 public: | 51 public: |
51 // lifeline_fd: this is the read end of a pipe which the browser process | 52 // lifeline_fd: this is the read end of a pipe which the browser process |
52 // holds the other end of. If the browser process dies, its descriptors are | 53 // holds the other end of. If the browser process dies, its descriptors are |
53 // closed and we will noticed an EOF on the pipe. That's our signal to exit. | 54 // closed and we will noticed an EOF on the pipe. That's our signal to exit. |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 if (HANDLE_EINTR(sendmsg(fds[0], &msg, MSG_DONTWAIT)) < 0) | 662 if (HANDLE_EINTR(sendmsg(fds[0], &msg, MSG_DONTWAIT)) < 0) |
662 PLOG(ERROR) << "sendmsg"; | 663 PLOG(ERROR) << "sendmsg"; |
663 } | 664 } |
664 | 665 |
665 // --------------------------------------------------------------------------- | 666 // --------------------------------------------------------------------------- |
666 | 667 |
667 const int lifeline_fd_; | 668 const int lifeline_fd_; |
668 const int browser_socket_; | 669 const int browser_socket_; |
669 scoped_ptr<FontConfigDirect> font_config_; | 670 scoped_ptr<FontConfigDirect> font_config_; |
670 std::vector<std::string> sandbox_cmd_; | 671 std::vector<std::string> sandbox_cmd_; |
671 scoped_ptr<content::WebKitPlatformSupportImpl> webkit_platform_support_; | 672 scoped_ptr<WebKitPlatformSupportImpl> webkit_platform_support_; |
672 }; | 673 }; |
673 | 674 |
674 SandboxIPCProcess::~SandboxIPCProcess() { | 675 SandboxIPCProcess::~SandboxIPCProcess() { |
675 if (webkit_platform_support_.get()) | 676 if (webkit_platform_support_.get()) |
676 WebKit::shutdown(); | 677 WebKit::shutdown(); |
677 } | 678 } |
678 | 679 |
679 void SandboxIPCProcess::EnsureWebKitInitialized() { | 680 void SandboxIPCProcess::EnsureWebKitInitialized() { |
680 if (webkit_platform_support_.get()) | 681 if (webkit_platform_support_.get()) |
681 return; | 682 return; |
682 webkit_platform_support_.reset(new content::WebKitPlatformSupportImpl); | 683 webkit_platform_support_.reset(new WebKitPlatformSupportImpl); |
683 WebKit::initializeWithoutV8(webkit_platform_support_.get()); | 684 WebKit::initializeWithoutV8(webkit_platform_support_.get()); |
684 } | 685 } |
685 | 686 |
686 // ----------------------------------------------------------------------------- | 687 // ----------------------------------------------------------------------------- |
687 | 688 |
688 // Runs on the main thread at startup. | 689 // Runs on the main thread at startup. |
689 RenderSandboxHostLinux::RenderSandboxHostLinux() | 690 RenderSandboxHostLinux::RenderSandboxHostLinux() |
690 : initialized_(false), | 691 : initialized_(false), |
691 renderer_socket_(0), | 692 renderer_socket_(0), |
692 childs_lifeline_fd_(0), | 693 childs_lifeline_fd_(0), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 } | 741 } |
741 | 742 |
742 RenderSandboxHostLinux::~RenderSandboxHostLinux() { | 743 RenderSandboxHostLinux::~RenderSandboxHostLinux() { |
743 if (initialized_) { | 744 if (initialized_) { |
744 if (HANDLE_EINTR(close(renderer_socket_)) < 0) | 745 if (HANDLE_EINTR(close(renderer_socket_)) < 0) |
745 PLOG(ERROR) << "close"; | 746 PLOG(ERROR) << "close"; |
746 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) | 747 if (HANDLE_EINTR(close(childs_lifeline_fd_)) < 0) |
747 PLOG(ERROR) << "close"; | 748 PLOG(ERROR) << "close"; |
748 } | 749 } |
749 } | 750 } |
| 751 |
| 752 } // namespace content |
OLD | NEW |