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_H_ | 5 #ifndef CONTENT_PUBLIC_APP_CONTENT_MAIN_H_ |
6 #define CONTENT_PUBLIC_APP_CONTENT_MAIN_H_ | 6 #define CONTENT_PUBLIC_APP_CONTENT_MAIN_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 | 13 |
14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
15 #include <windows.h> | 15 #include <windows.h> |
16 #endif | 16 #endif |
17 | 17 |
18 #if defined(USE_AURA) | 18 #if defined(USE_AURA) |
19 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
20 #endif | 20 #endif |
21 | 21 |
| 22 namespace base { |
| 23 namespace mac { |
| 24 class ScopedNSAutoreleasePool; |
| 25 } |
| 26 } |
| 27 |
22 namespace sandbox { | 28 namespace sandbox { |
23 struct SandboxInterfaceInfo; | 29 struct SandboxInterfaceInfo; |
24 } | 30 } |
25 | 31 |
26 namespace content { | 32 namespace content { |
27 class ContentMainDelegate; | 33 class ContentMainDelegate; |
28 | 34 |
29 struct ContentMainParams { | 35 struct ContentMainParams { |
30 explicit ContentMainParams(ContentMainDelegate* delegate) | 36 explicit ContentMainParams(ContentMainDelegate* delegate) |
31 : delegate(delegate), | 37 : delegate(delegate) {} |
32 #if defined(OS_WIN) | |
33 instance(NULL), | |
34 sandbox_info(NULL), | |
35 #elif !defined(OS_ANDROID) | |
36 argc(0), | |
37 argv(NULL), | |
38 #endif | |
39 ui_task(NULL) { | |
40 } | |
41 | 38 |
42 ContentMainDelegate* delegate; | 39 ContentMainDelegate* delegate; |
43 | 40 |
44 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
45 HINSTANCE instance; | 42 HINSTANCE instance = nullptr; |
46 | 43 |
47 // |sandbox_info| should be initialized using InitializeSandboxInfo from | 44 // |sandbox_info| should be initialized using InitializeSandboxInfo from |
48 // content_main_win.h | 45 // content_main_win.h |
49 sandbox::SandboxInterfaceInfo* sandbox_info; | 46 sandbox::SandboxInterfaceInfo* sandbox_info = nullptr; |
50 #elif !defined(OS_ANDROID) | 47 #elif !defined(OS_ANDROID) |
51 int argc; | 48 int argc = 0; |
52 const char** argv; | 49 const char** argv = nullptr; |
53 #endif | 50 #endif |
54 | 51 |
55 // Used by browser_tests. If non-null BrowserMain schedules this task to run | 52 // Used by browser_tests. If non-null BrowserMain schedules this task to run |
56 // on the MessageLoop. It's owned by the test code. | 53 // on the MessageLoop. It's owned by the test code. |
57 base::Closure* ui_task; | 54 base::Closure* ui_task = nullptr; |
58 | 55 |
59 #if defined(USE_AURA) | 56 #if defined(USE_AURA) |
60 aura::Env::Mode env_mode = aura::Env::Mode::LOCAL; | 57 aura::Env::Mode env_mode = aura::Env::Mode::LOCAL; |
61 #endif | 58 #endif |
| 59 |
| 60 #if defined(OS_MACOSX) |
| 61 // The outermost autorelease pool to pass to main entry points. |
| 62 base::mac::ScopedNSAutoreleasePool* autorelease_pool = nullptr; |
| 63 #endif |
62 }; | 64 }; |
63 | 65 |
64 #if defined(OS_ANDROID) | 66 #if defined(OS_ANDROID) |
65 // In the Android, the content main starts from ContentMain.java, This function | 67 // In the Android, the content main starts from ContentMain.java, This function |
66 // provides a way to set the |delegate| as ContentMainDelegate for | 68 // provides a way to set the |delegate| as ContentMainDelegate for |
67 // ContentMainRunner. | 69 // ContentMainRunner. |
68 // This should only be called once before ContentMainRunner actually running. | 70 // This should only be called once before ContentMainRunner actually running. |
69 // The ownership of |delegate| is transferred. | 71 // The ownership of |delegate| is transferred. |
70 CONTENT_EXPORT void SetContentMainDelegate(ContentMainDelegate* delegate); | 72 CONTENT_EXPORT void SetContentMainDelegate(ContentMainDelegate* delegate); |
71 #else | 73 #else |
72 // ContentMain should be called from the embedder's main() function to do the | 74 // ContentMain should be called from the embedder's main() function to do the |
73 // initial setup for every process. The embedder has a chance to customize | 75 // initial setup for every process. The embedder has a chance to customize |
74 // startup using the ContentMainDelegate interface. The embedder can also pass | 76 // startup using the ContentMainDelegate interface. The embedder can also pass |
75 // in NULL for |delegate| if they don't want to override default startup. | 77 // in NULL for |delegate| if they don't want to override default startup. |
76 CONTENT_EXPORT int ContentMain(const ContentMainParams& params); | 78 CONTENT_EXPORT int ContentMain(const ContentMainParams& params); |
77 #endif | 79 #endif |
78 | 80 |
79 } // namespace content | 81 } // namespace content |
80 | 82 |
81 #endif // CONTENT_PUBLIC_APP_CONTENT_MAIN_H_ | 83 #endif // CONTENT_PUBLIC_APP_CONTENT_MAIN_H_ |
OLD | NEW |