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 #include "chrome/app/android/chrome_main_delegate_android.h" | 5 #include "chrome/app/android/chrome_main_delegate_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/memory/scoped_ptr.h" | |
9 #include "chrome/browser/android/chrome_jni_registrar.h" | 10 #include "chrome/browser/android/chrome_jni_registrar.h" |
10 #include "chrome/browser/android/chrome_startup_flags.h" | 11 #include "chrome/browser/android/chrome_startup_flags.h" |
11 #include "content/public/browser/browser_main_runner.h" | 12 #include "content/public/browser/browser_main_runner.h" |
12 | 13 |
13 // ChromeMainDelegateAndroid is created when the library is loaded. It is always | 14 // ChromeMainDelegateAndroid is created when the library is loaded. It is always |
14 // done in the process's main Java thread. But for non browser process, e.g. | 15 // done in the process's main Java thread. But for non browser process, e.g. |
15 // renderer process, it is not the native Chrome's main thread. | 16 // renderer process, it is not the native Chrome's main thread. |
16 ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() { | 17 ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() |
17 } | 18 : incremental_startup_enabled_(false) {} |
18 | 19 |
19 ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() { | 20 ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() { |
20 } | 21 } |
21 | 22 |
22 void ChromeMainDelegateAndroid::SandboxInitialized( | 23 void ChromeMainDelegateAndroid::SandboxInitialized( |
23 const std::string& process_type) { | 24 const std::string& process_type) { |
24 ChromeMainDelegate::SandboxInitialized(process_type); | 25 ChromeMainDelegate::SandboxInitialized(process_type); |
25 } | 26 } |
26 | 27 |
27 int ChromeMainDelegateAndroid::RunProcess( | 28 int ChromeMainDelegateAndroid::RunProcess( |
28 const std::string& process_type, | 29 const std::string& process_type, |
29 const content::MainFunctionParams& main_function_params) { | 30 const content::MainFunctionParams& main_function_params) { |
30 TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess") | 31 TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess") |
31 if (process_type.empty()) { | 32 if (process_type.empty()) { |
32 JNIEnv* env = base::android::AttachCurrentThread(); | 33 JNIEnv* env = base::android::AttachCurrentThread(); |
33 RegisterApplicationNativeMethods(env); | 34 RegisterApplicationNativeMethods(env); |
34 | 35 |
35 browser_runner_.reset(content::BrowserMainRunner::Create()); | 36 browser_runner_.reset(content::BrowserMainRunner::Create()); |
36 return browser_runner_->Initialize(main_function_params); | 37 |
38 // For Chrome on android we want to run the startup tasks incrementally, so | |
Yaron
2013/07/23 02:14:03
Any reason not to do this on testshell as well and
aberent
2013/07/23 13:45:03
This has to be conditional, since there are a numb
| |
39 // that UI tasks can get in in-between. | |
40 content::StartupTaskRunner::StartupMode mode = | |
41 incremental_startup_enabled_ ? content::StartupTaskRunner::INCREMENTAL | |
42 : content::StartupTaskRunner::IMMEDIATE; | |
43 scoped_refptr<content::StartupTaskRunner> startup_task_runner( | |
44 new content::StartupTaskRunner(mode, GetStartupObserver())); | |
45 | |
46 return browser_runner_->Initialize(main_function_params, | |
47 startup_task_runner); | |
37 } | 48 } |
38 | 49 |
39 return ChromeMainDelegate::RunProcess(process_type, main_function_params); | 50 return ChromeMainDelegate::RunProcess(process_type, main_function_params); |
40 } | 51 } |
41 | 52 |
42 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { | 53 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { |
43 SetChromeSpecificCommandLineFlags(); | 54 SetChromeSpecificCommandLineFlags(); |
44 return ChromeMainDelegate::BasicStartupComplete(exit_code); | 55 return ChromeMainDelegate::BasicStartupComplete(exit_code); |
45 } | 56 } |
46 | 57 |
47 bool ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(JNIEnv* env) { | 58 bool ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(JNIEnv* env) { |
48 return chrome::android::RegisterJni(env); | 59 return chrome::android::RegisterJni(env); |
49 } | 60 } |
61 | |
62 void ChromeMainDelegateAndroid::EnableIncrementalStartup(bool enable) { | |
63 incremental_startup_enabled_ = enable; | |
64 } | |
OLD | NEW |