| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_APP_CONTENT_MAIN_DELEGATE_H_ | 5 #ifndef CONTENT_APP_CONTENT_MAIN_DELEGATE_H_ |
| 6 #define CONTENT_APP_CONTENT_MAIN_DELEGATE_H_ | 6 #define CONTENT_APP_CONTENT_MAIN_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 | 12 |
| 13 struct MainFunctionParams; | 13 struct MainFunctionParams; |
| 14 class ZygoteForkDelegate; | 14 class ZygoteForkDelegate; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class ContentMainDelegate { | 18 class ContentMainDelegate { |
| 19 public: | 19 public: |
| 20 virtual ~ContentMainDelegate(); |
| 21 |
| 20 // Tells the embedder that the absolute basic startup has been done, i.e. it's | 22 // Tells the embedder that the absolute basic startup has been done, i.e. it's |
| 21 // now safe to create singletons and check the command line. Return true if | 23 // now safe to create singletons and check the command line. Return true if |
| 22 // the process should exit afterwards, and if so, |exit_code| should be set. | 24 // the process should exit afterwards, and if so, |exit_code| should be set. |
| 23 // This is the place for embedder to do the things that must happen at the | 25 // This is the place for embedder to do the things that must happen at the |
| 24 // start. Most of its startup code should be in the methods below. | 26 // start. Most of its startup code should be in the methods below. |
| 25 virtual bool BasicStartupComplete(int* exit_code) = 0; | 27 virtual bool BasicStartupComplete(int* exit_code); |
| 26 | 28 |
| 27 // This is where the embedder puts all of its startup code that needs to run | 29 // This is where the embedder puts all of its startup code that needs to run |
| 28 // before the sandbox is engaged. | 30 // before the sandbox is engaged. |
| 29 virtual void PreSandboxStartup() = 0; | 31 virtual void PreSandboxStartup(); |
| 30 | 32 |
| 31 // This is where the embedder can add startup code to run after the sandbox | 33 // This is where the embedder can add startup code to run after the sandbox |
| 32 // has been initialized. | 34 // has been initialized. |
| 33 virtual void SandboxInitialized(const std::string& process_type) = 0; | 35 virtual void SandboxInitialized(const std::string& process_type); |
| 34 | 36 |
| 35 // Asks the embedder to start a process that content doesn't know about. | 37 // Asks the embedder to start a process that content doesn't know about. |
| 36 virtual int RunProcess(const std::string& process_type, | 38 virtual int RunProcess(const std::string& process_type, |
| 37 const MainFunctionParams& main_function_params) = 0; | 39 const MainFunctionParams& main_function_params); |
| 38 | 40 |
| 39 // Called right before the process exits. | 41 // Called right before the process exits. |
| 40 virtual void ProcessExiting(const std::string& process_type) = 0; | 42 virtual void ProcessExiting(const std::string& process_type); |
| 41 | 43 |
| 42 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
| 43 // Returns true if the process registers with the system monitor, so that we | 45 // Returns true if the process registers with the system monitor, so that we |
| 44 // can allocate an IO port for it before the sandbox is initialized. Embedders | 46 // can allocate an IO port for it before the sandbox is initialized. Embedders |
| 45 // are called only for process types that content doesn't know about. | 47 // are called only for process types that content doesn't know about. |
| 46 virtual bool ProcessRegistersWithSystemProcess( | 48 virtual bool ProcessRegistersWithSystemProcess( |
| 47 const std::string& process_type) = 0; | 49 const std::string& process_type); |
| 48 | 50 |
| 49 // Used to determine if we should send the mach port to the parent process or | 51 // Used to determine if we should send the mach port to the parent process or |
| 50 // not. The embedder usually sends it for all child processes, use this to | 52 // not. The embedder usually sends it for all child processes, use this to |
| 51 // override this behavior. | 53 // override this behavior. |
| 52 virtual bool ShouldSendMachPort(const std::string& process_type) = 0; | 54 virtual bool ShouldSendMachPort(const std::string& process_type); |
| 53 | 55 |
| 54 // Allows the embedder to override initializing the sandbox. This is needed | 56 // Allows the embedder to override initializing the sandbox. This is needed |
| 55 // because some processes might not want to enable it right away or might not | 57 // because some processes might not want to enable it right away or might not |
| 56 // want it at all. | 58 // want it at all. |
| 57 virtual bool DelaySandboxInitialization(const std::string& process_type) = 0; | 59 virtual bool DelaySandboxInitialization(const std::string& process_type); |
| 60 |
| 58 #elif defined(OS_POSIX) | 61 #elif defined(OS_POSIX) |
| 59 // Tells the embedder that the zygote process is starting, and allows it to | 62 // Tells the embedder that the zygote process is starting, and allows it to |
| 60 // specify a zygote delegate if it wishes. | 63 // specify a zygote delegate if it wishes. |
| 61 virtual ZygoteForkDelegate* ZygoteStarting() = 0; | 64 virtual ZygoteForkDelegate* ZygoteStarting(); |
| 62 | 65 |
| 63 // Called every time the zygote process forks. | 66 // Called every time the zygote process forks. |
| 64 virtual void ZygoteForked() = 0; | 67 virtual void ZygoteForked(); |
| 65 #endif // OS_MACOSX | 68 #endif // OS_MACOSX |
| 66 }; | 69 }; |
| 67 | 70 |
| 68 } // namespace content | 71 } // namespace content |
| 69 | 72 |
| 70 #endif // CONTENT_APP_CONTENT_MAIN_DELEGATE_H_ | 73 #endif // CONTENT_APP_CONTENT_MAIN_DELEGATE_H_ |
| OLD | NEW |