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 #ifndef CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_ | 5 #ifndef CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_ |
6 #define CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_ | 6 #define CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/public/common/startup_task_runner.h" |
12 | 13 |
13 namespace content { | 14 namespace content { |
14 | 15 |
15 class ContentBrowserClient; | 16 class ContentBrowserClient; |
16 class ContentPluginClient; | 17 class ContentPluginClient; |
17 class ContentRendererClient; | 18 class ContentRendererClient; |
18 class ContentUtilityClient; | 19 class ContentUtilityClient; |
19 class ZygoteForkDelegate; | 20 class ZygoteForkDelegate; |
20 struct MainFunctionParams; | 21 struct MainFunctionParams; |
21 | 22 |
22 class CONTENT_EXPORT ContentMainDelegate { | 23 class CONTENT_EXPORT ContentMainDelegate { |
23 public: | 24 public: |
| 25 ContentMainDelegate() {} |
24 virtual ~ContentMainDelegate() {} | 26 virtual ~ContentMainDelegate() {} |
25 | 27 |
26 // Tells the embedder that the absolute basic startup has been done, i.e. | 28 // Tells the embedder that the absolute basic startup has been done, i.e. |
27 // it's now safe to create singletons and check the command line. Return true | 29 // it's now safe to create singletons and check the command line. Return true |
28 // if the process should exit afterwards, and if so, |exit_code| should be | 30 // if the process should exit afterwards, and if so, |exit_code| should be |
29 // set. This is the place for embedder to do the things that must happen at | 31 // set. This is the place for embedder to do the things that must happen at |
30 // the start. Most of its startup code should be in the methods below. | 32 // the start. Most of its startup code should be in the methods below. |
31 virtual bool BasicStartupComplete(int* exit_code); | 33 virtual bool BasicStartupComplete(int* exit_code); |
32 | 34 |
33 // This is where the embedder puts all of its startup code that needs to run | 35 // This is where the embedder puts all of its startup code that needs to run |
34 // before the sandbox is engaged. | 36 // before the sandbox is engaged. |
35 virtual void PreSandboxStartup() {} | 37 virtual void PreSandboxStartup() {} |
36 | 38 |
37 // This is where the embedder can add startup code to run after the sandbox | 39 // This is where the embedder can add startup code to run after the sandbox |
38 // has been initialized. | 40 // has been initialized. |
39 virtual void SandboxInitialized(const std::string& process_type) {} | 41 virtual void SandboxInitialized(const std::string& process_type) {} |
40 | 42 |
41 // Asks the embedder to start a process. Return -1 for the default behavior. | 43 // Asks the embedder to start a process. Return -1 for the default behavior. |
42 virtual int RunProcess( | 44 virtual int RunProcess( |
43 const std::string& process_type, | 45 const std::string& process_type, |
44 const MainFunctionParams& main_function_params); | 46 const MainFunctionParams& main_function_params); |
45 | 47 |
46 // Called right before the process exits. | 48 // Called right before the process exits. |
47 virtual void ProcessExiting(const std::string& process_type) {} | 49 virtual void ProcessExiting(const std::string& process_type) {} |
48 | 50 |
| 51 // Call with true to allow the creation of a sequence of UI thread tasks to |
| 52 // initialize the content layer. If not called, or called with false, content |
| 53 // layer initialization must be completed in a single UI task. |
| 54 // If called with true it is an implementation choice whether initialization |
| 55 // requires multiple UI thread tasks. |
| 56 virtual void EnableIncrementalStartup(bool enable) {}; |
| 57 |
| 58 // Set an observer to inform higher layers of startup progress |
| 59 virtual void SetStartupObserver( |
| 60 scoped_ptr<StartupTaskRunner::Observer> observer); |
| 61 |
49 #if defined(OS_MACOSX) && !defined(OS_IOS) | 62 #if defined(OS_MACOSX) && !defined(OS_IOS) |
50 // Returns true if the process registers with the system monitor, so that we | 63 // Returns true if the process registers with the system monitor, so that we |
51 // can allocate an IO port for it before the sandbox is initialized. Embedders | 64 // can allocate an IO port for it before the sandbox is initialized. Embedders |
52 // are called only for process types that content doesn't know about. | 65 // are called only for process types that content doesn't know about. |
53 virtual bool ProcessRegistersWithSystemProcess( | 66 virtual bool ProcessRegistersWithSystemProcess( |
54 const std::string& process_type); | 67 const std::string& process_type); |
55 | 68 |
56 // Used to determine if we should send the mach port to the parent process or | 69 // Used to determine if we should send the mach port to the parent process or |
57 // not. The embedder usually sends it for all child processes, use this to | 70 // not. The embedder usually sends it for all child processes, use this to |
58 // override this behavior. | 71 // override this behavior. |
(...skipping 16 matching lines...) Expand all Loading... |
75 protected: | 88 protected: |
76 friend class ContentClientInitializer; | 89 friend class ContentClientInitializer; |
77 | 90 |
78 // Called once per relevant process type to allow the embedder to customize | 91 // Called once per relevant process type to allow the embedder to customize |
79 // content. If an embedder wants the default (empty) implementation, don't | 92 // content. If an embedder wants the default (empty) implementation, don't |
80 // override this. | 93 // override this. |
81 virtual ContentBrowserClient* CreateContentBrowserClient(); | 94 virtual ContentBrowserClient* CreateContentBrowserClient(); |
82 virtual ContentPluginClient* CreateContentPluginClient(); | 95 virtual ContentPluginClient* CreateContentPluginClient(); |
83 virtual ContentRendererClient* CreateContentRendererClient(); | 96 virtual ContentRendererClient* CreateContentRendererClient(); |
84 virtual ContentUtilityClient* CreateContentUtilityClient(); | 97 virtual ContentUtilityClient* CreateContentUtilityClient(); |
| 98 |
| 99 StartupTaskRunner::Observer* GetStartupObserver(); |
| 100 |
| 101 private: |
| 102 scoped_ptr<StartupTaskRunner::Observer> startup_observer_; |
85 }; | 103 }; |
86 | 104 |
87 } // namespace content | 105 } // namespace content |
88 | 106 |
89 #endif // CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_ | 107 #endif // CONTENT_PUBLIC_APP_CONTENT_MAIN_DELEGATE_H_ |
OLD | NEW |