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 "chrome/browser/android/chrome_jni_registrar.h" | 9 #include "chrome/browser/android/chrome_jni_registrar.h" |
10 #include "chrome/browser/android/chrome_startup_flags.h" | 10 #include "chrome/browser/android/chrome_startup_flags.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 int ChromeMainDelegateAndroid::RunProcess( | 27 int ChromeMainDelegateAndroid::RunProcess( |
28 const std::string& process_type, | 28 const std::string& process_type, |
29 const content::MainFunctionParams& main_function_params) { | 29 const content::MainFunctionParams& main_function_params) { |
30 TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess") | 30 TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess") |
31 if (process_type.empty()) { | 31 if (process_type.empty()) { |
32 JNIEnv* env = base::android::AttachCurrentThread(); | 32 JNIEnv* env = base::android::AttachCurrentThread(); |
33 RegisterApplicationNativeMethods(env); | 33 RegisterApplicationNativeMethods(env); |
34 | 34 |
35 browser_runner_.reset(content::BrowserMainRunner::Create()); | 35 // Because the browser process can be started asynchronously as a series of |
| 36 // of UI thread tasks a second request to start it can come in while the |
| 37 // first request is still being processed. We must keep the same |
| 38 // browser runner for the second request. |
| 39 if (!browser_runner_.get()) { |
| 40 browser_runner_.reset(content::BrowserMainRunner::Create()); |
| 41 } |
36 return browser_runner_->Initialize(main_function_params); | 42 return browser_runner_->Initialize(main_function_params); |
37 } | 43 } |
38 | 44 |
39 return ChromeMainDelegate::RunProcess(process_type, main_function_params); | 45 return ChromeMainDelegate::RunProcess(process_type, main_function_params); |
40 } | 46 } |
41 | 47 |
42 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { | 48 bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { |
43 SetChromeSpecificCommandLineFlags(); | 49 SetChromeSpecificCommandLineFlags(); |
44 return ChromeMainDelegate::BasicStartupComplete(exit_code); | 50 return ChromeMainDelegate::BasicStartupComplete(exit_code); |
45 } | 51 } |
46 | 52 |
47 bool ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(JNIEnv* env) { | 53 bool ChromeMainDelegateAndroid::RegisterApplicationNativeMethods(JNIEnv* env) { |
48 return chrome::android::RegisterJni(env); | 54 return chrome::android::RegisterJni(env); |
49 } | 55 } |
OLD | NEW |