| Index: content/browser/android/browser_process_main.cc
|
| diff --git a/content/browser/android/browser_process_main.cc b/content/browser/android/browser_process_main.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8ff68f10db6c0333961729a7acf13248768466e2
|
| --- /dev/null
|
| +++ b/content/browser/android/browser_process_main.cc
|
| @@ -0,0 +1,113 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/android/browser_process_main.h"
|
| +
|
| +#include "base/android/jni_string.h"
|
| +#include "base/base_switches.h"
|
| +#include "base/command_line.h"
|
| +#include "base/debug/debugger.h"
|
| +#include "base/logging.h"
|
| +#include "content/browser/android/command_line.h"
|
| +#if !defined(ANDROID_UPSTREAM_BRINGUP)
|
| +#include "content/browser/android/content_startup_flags.h"
|
| +#endif
|
| +#include "content/browser/device_orientation/data_fetcher_impl_android.h"
|
| +#if !defined(ANDROID_UPSTREAM_BRINGUP)
|
| +#include "content/browser/geolocation/android_location_api_adapter.h"
|
| +#endif
|
| +#include "content/common/android/process_main.h"
|
| +#if !defined(ANDROID_UPSTREAM_BRINGUP)
|
| +#include "content/common/android/surface_texture_peer.h"
|
| +#endif
|
| +#include "content/public/app/content_main_runner.h"
|
| +#include "content/public/common/content_constants.h"
|
| +#include "jni/browser_process_main_jni.h"
|
| +
|
| +using base::android::ConvertJavaStringToUTF8;
|
| +
|
| +namespace {
|
| +
|
| +content::ContentMainRunner* g_content_runner = NULL;
|
| +
|
| +#if !defined(ANDROID_UPSTREAM_BRINGUP)
|
| +
|
| +class SurfaceTexturePeerBrowserImpl : public SurfaceTexturePeer {
|
| + public:
|
| + SurfaceTexturePeerBrowserImpl() {
|
| + }
|
| +
|
| + virtual ~SurfaceTexturePeerBrowserImpl() {
|
| + }
|
| +
|
| + virtual void EstablishSurfaceTexturePeer(base::ProcessHandle pid,
|
| + SurfaceTextureTarget type,
|
| + jobject j_surface_texture,
|
| + int primary_id,
|
| + int secondary_id) {
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + DCHECK(env);
|
| + Java_BrowserProcessMain_establishSurfaceTexturePeer(env, pid, type,
|
| + j_surface_texture, primary_id, secondary_id);
|
| + }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerBrowserImpl);
|
| +};
|
| +
|
| +#endif // !defined(ANDROID_UPSTREAM_BRINGUP)
|
| +
|
| +} // namespace <anonymous>
|
| +
|
| +static void InitBrowserProcess(JNIEnv* env, jclass /* clazz */,
|
| + jobject context,
|
| + jint max_render_process_count,
|
| + jstring plugin_descriptor) {
|
| + if (g_content_runner) {
|
| + LOG(WARNING) << "InitBrowserProcess has been called before";
|
| + return;
|
| + }
|
| +
|
| + const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
|
| + if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) {
|
| + LOG(ERROR) << "Browser waiting for GDB because flag "
|
| + << switches::kWaitForDebugger << " was supplied.";
|
| + base::debug::WaitForDebugger(24*60*60, false);
|
| + }
|
| +
|
| + std::string plugin_str = ConvertJavaStringToUTF8(env, plugin_descriptor);
|
| +#if !defined(ANDROID_UPSTREAM_BRINGUP)
|
| + SetContentCommandLineFlags(max_render_process_count, plugin_str);
|
| +#endif
|
| + if (!InitProcess(env, context))
|
| + return;
|
| +
|
| + // common initialization.
|
| +#if !defined(ANDROID_UPSTREAM_BRINGUP)
|
| + SurfaceTexturePeer::InitInstance(new SurfaceTexturePeerBrowserImpl());
|
| + device_orientation::DataFetcherImplAndroid::Init(env);
|
| + AndroidLocationApiAdapter::RegisterGeolocationService(env);
|
| +#endif
|
| + // start ContentMainRunner
|
| + g_content_runner = content::ContentMainRunner::Create();
|
| + DCHECK(g_content_runner);
|
| +
|
| + g_content_runner->Initialize(0, NULL, g_content_main_delegate);
|
| +
|
| + g_content_runner->Run();
|
| +
|
| + return;
|
| +}
|
| +
|
| +static jboolean IsOfficialBuild(JNIEnv* env, jclass /* clazz */) {
|
| +#if defined(OFFICIAL_BUILD)
|
| + return true;
|
| +#else
|
| + return false;
|
| +#endif
|
| +}
|
| +
|
| +bool RegisterBrowserProcessMain(JNIEnv* env) {
|
| + return RegisterNativesImpl(env);
|
| +}
|
|
|