Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / browser / zygote_host / zygote_host_impl_linux.h
blob6a1aca5ba79c57570f6e65b9e50ed68658417c5f
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.
5 #ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
6 #define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_
8 #include <string>
9 #include <vector>
11 #include "base/pickle.h"
12 #include "base/process/kill.h"
13 #include "base/synchronization/lock.h"
14 #include "content/public/browser/file_descriptor_info.h"
15 #include "content/public/browser/zygote_host_linux.h"
17 template<typename Type>
18 struct DefaultSingletonTraits;
20 namespace content {
22 class CONTENT_EXPORT ZygoteHostImpl : public ZygoteHost {
23 public:
24 // Returns the singleton instance.
25 static ZygoteHostImpl* GetInstance();
27 void Init(const std::string& sandbox_cmd);
29 // Tries to start a process of type indicated by process_type.
30 // Returns its pid on success, otherwise
31 // base::kNullProcessHandle;
32 pid_t ForkRequest(const std::vector<std::string>& command_line,
33 const std::vector<FileDescriptorInfo>& mapping,
34 const std::string& process_type);
35 void EnsureProcessTerminated(pid_t process);
37 // Get the termination status (and, optionally, the exit code) of
38 // the process. |exit_code| is set to the exit code of the child
39 // process. (|exit_code| may be NULL.)
40 // Unfortunately the Zygote can not accurately figure out if a process
41 // is already dead without waiting synchronously for it.
42 // |known_dead| should be set to true when we already know that the process
43 // is dead. When |known_dead| is false, processes could be seen as
44 // still running, even when they're not. When |known_dead| is true, the
45 // process will be SIGKILL-ed first (which should have no effect if it was
46 // really dead). This is to prevent a waiting waitpid() from blocking in
47 // a single-threaded Zygote. See crbug.com/157458.
48 base::TerminationStatus GetTerminationStatus(base::ProcessHandle handle,
49 bool known_dead,
50 int* exit_code);
52 // ZygoteHost implementation:
53 virtual pid_t GetPid() const OVERRIDE;
54 virtual pid_t GetSandboxHelperPid() const OVERRIDE;
55 virtual int GetSandboxStatus() const OVERRIDE;
56 virtual void AdjustRendererOOMScore(base::ProcessHandle process_handle,
57 int score) OVERRIDE;
58 virtual void AdjustLowMemoryMargin(int64 margin_mb) OVERRIDE;
60 private:
61 friend struct DefaultSingletonTraits<ZygoteHostImpl>;
63 ZygoteHostImpl();
64 virtual ~ZygoteHostImpl();
66 // Sends |data| to the zygote via |control_fd_|. If |fds| is non-NULL, the
67 // included file descriptors will also be passed. The caller is responsible
68 // for acquiring |control_lock_|.
69 bool SendMessage(const Pickle& data, const std::vector<int>* fds);
71 ssize_t ReadReply(void* buf, size_t buflen);
73 int control_fd_; // the socket to the zygote
74 // A lock protecting all communication with the zygote. This lock must be
75 // acquired before sending a command and released after the result has been
76 // received.
77 base::Lock control_lock_;
78 pid_t pid_;
79 bool init_;
80 bool using_suid_sandbox_;
81 std::string sandbox_binary_;
82 bool have_read_sandbox_status_word_;
83 int sandbox_status_;
86 } // namespace content
88 #endif // CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_