Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: chrome/app/android/chrome_main_delegate_android.cc

Issue 19957002: Run the later parts of startup as UI thread tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Run the later parts of startup as UI thread tasks - patch for Joth's comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698