By moving the call to Load() up in SearchProvider::Start(), we are giving a chance...
[chromium-blink-merge.git] / content / browser / utility_process_host_impl.h
blob4922e9cc956903eae527a075d20d0e2e295a40f9
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/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/public/browser/browser_child_process_host_delegate.h"
17 #include "content/public/browser/utility_process_host.h"
19 namespace base {
20 class SequencedTaskRunner;
23 namespace content {
24 class BrowserChildProcessHostImpl;
26 class CONTENT_EXPORT UtilityProcessHostImpl
27 : public NON_EXPORTED_BASE(UtilityProcessHost),
28 public BrowserChildProcessHostDelegate {
29 public:
30 UtilityProcessHostImpl(UtilityProcessHostClient* client,
31 base::SequencedTaskRunner* client_task_runner);
32 virtual ~UtilityProcessHostImpl();
34 // UtilityProcessHost implementation:
35 virtual bool Send(IPC::Message* message) OVERRIDE;
36 virtual bool StartBatchMode() OVERRIDE;
37 virtual void EndBatchMode() OVERRIDE;
38 virtual void SetExposedDir(const FilePath& dir) OVERRIDE;
39 virtual void DisableSandbox() OVERRIDE;
40 virtual void EnableZygote() OVERRIDE;
41 virtual const ChildProcessData& GetData() OVERRIDE;
42 #if defined(OS_POSIX)
43 virtual void SetEnv(const base::EnvironmentVector& env) OVERRIDE;
44 #endif
46 void set_child_flags(int flags) { child_flags_ = flags; }
48 private:
49 // Starts a process if necessary. Returns true if it succeeded or a process
50 // has already been started via StartBatchMode().
51 bool StartProcess();
53 // BrowserChildProcessHost:
54 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
55 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
57 // A pointer to our client interface, who will be informed of progress.
58 scoped_refptr<UtilityProcessHostClient> client_;
59 scoped_refptr<base::SequencedTaskRunner> client_task_runner_;
60 // True when running in batch mode, i.e., StartBatchMode() has been called
61 // and the utility process will run until EndBatchMode().
62 bool is_batch_mode_;
64 FilePath exposed_dir_;
66 // Whether to pass switches::kNoSandbox to the child.
67 bool no_sandbox_;
69 // Flags defined in ChildProcessHost with which to start the process.
70 int child_flags_;
72 // Launch the utility process from the zygote. Defaults to false.
73 bool use_linux_zygote_;
75 base::EnvironmentVector env_;
77 bool started_;
79 scoped_ptr<BrowserChildProcessHostImpl> process_;
81 DISALLOW_COPY_AND_ASSIGN(UtilityProcessHostImpl);
84 } // namespace content
86 #endif // CONTENT_BROWSER_UTILITY_PROCESS_HOST_IMPL_H_