Cast: Skip receiver log messages with time delta that can't be encoded.
[chromium-blink-merge.git] / content / browser / utility_process_host_impl.h
blobdd663dd347c945a23ad0db23e621f0fb68d6343b
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_UTILITY_PROCESS_HOST_IMPL_H_
6 #define CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h"
17 #include "content/public/browser/browser_child_process_host_delegate.h"
18 #include "content/public/browser/utility_process_host.h"
20 namespace base {
21 class SequencedTaskRunner;
22 class Thread;
25 namespace content {
26 class BrowserChildProcessHostImpl;
28 class CONTENT_EXPORT UtilityProcessHostImpl
29 : public NON_EXPORTED_BASE(UtilityProcessHost),
30 public BrowserChildProcessHostDelegate {
31 public:
32 UtilityProcessHostImpl(UtilityProcessHostClient* client,
33 base::SequencedTaskRunner* client_task_runner);
34 virtual ~UtilityProcessHostImpl();
36 // UtilityProcessHost implementation:
37 virtual bool Send(IPC::Message* message) OVERRIDE;
38 virtual bool StartBatchMode() OVERRIDE;
39 virtual void EndBatchMode() OVERRIDE;
40 virtual void SetExposedDir(const base::FilePath& dir) OVERRIDE;
41 virtual void EnableMDns() OVERRIDE;
42 virtual void DisableSandbox() OVERRIDE;
43 #if defined(OS_WIN)
44 virtual void ElevatePrivileges() OVERRIDE;
45 #endif
46 virtual const ChildProcessData& GetData() OVERRIDE;
47 #if defined(OS_POSIX)
48 virtual void SetEnv(const base::EnvironmentMap& env) OVERRIDE;
49 #endif
51 void set_child_flags(int flags) { child_flags_ = flags; }
53 private:
54 // Starts a process if necessary. Returns true if it succeeded or a process
55 // has already been started via StartBatchMode().
56 bool StartProcess();
58 // BrowserChildProcessHost:
59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
60 virtual void OnProcessLaunchFailed() OVERRIDE;
61 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
63 // A pointer to our client interface, who will be informed of progress.
64 scoped_refptr<UtilityProcessHostClient> client_;
65 scoped_refptr<base::SequencedTaskRunner> client_task_runner_;
66 // True when running in batch mode, i.e., StartBatchMode() has been called
67 // and the utility process will run until EndBatchMode().
68 bool is_batch_mode_;
70 base::FilePath exposed_dir_;
72 // Whether the utility process needs to perform presandbox initialization
73 // for mDNS.
74 bool is_mdns_enabled_;
76 // Whether to pass switches::kNoSandbox to the child.
77 bool no_sandbox_;
79 #if defined(OS_WIN)
80 // Whether to launch the process with elevated privileges.
81 bool run_elevated_;
82 #endif
84 // Flags defined in ChildProcessHost with which to start the process.
85 int child_flags_;
87 base::EnvironmentMap env_;
89 bool started_;
91 scoped_ptr<BrowserChildProcessHostImpl> process_;
93 // Used in single-process mode instead of process_.
94 scoped_ptr<base::Thread> in_process_thread_;
96 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHostImpl);
99 } // namespace content
101 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_