| 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 "content/app/android/content_main.h" | 5 #include "content/app/android/content_main.h" |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace { | 22 namespace { |
| 23 LazyInstance<scoped_ptr<ContentMainRunner> > g_content_runner = | 23 LazyInstance<scoped_ptr<ContentMainRunner> > g_content_runner = |
| 24 LAZY_INSTANCE_INITIALIZER; | 24 LAZY_INSTANCE_INITIALIZER; |
| 25 | 25 |
| 26 LazyInstance<scoped_ptr<ContentMainDelegate> > g_content_main_delegate = | 26 LazyInstance<scoped_ptr<ContentMainDelegate> > g_content_main_delegate = |
| 27 LAZY_INSTANCE_INITIALIZER; | 27 LAZY_INSTANCE_INITIALIZER; |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 static void InitApplicationContext(JNIEnv* env, jclass clazz, jobject context) { | 31 static void InitApplicationContext(JNIEnv* env, jclass clazz, jobject context) { |
| 32 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); | 32 base::android::ScopedJavaLocalRef<jobject> scoped_context( |
| 33 env, env->NewLocalRef(context)); |
| 33 base::android::InitApplicationContext(env, scoped_context); | 34 base::android::InitApplicationContext(env, scoped_context); |
| 34 } | 35 } |
| 35 | 36 |
| 36 static jint Start(JNIEnv* env, jclass clazz) { | 37 static jint Start(JNIEnv* env, jclass clazz) { |
| 37 TRACE_EVENT0("startup", "content::Start"); | 38 TRACE_EVENT0("startup", "content::Start"); |
| 38 | 39 |
| 39 // On Android we can have multiple requests to start the browser in process | 40 // On Android we can have multiple requests to start the browser in process |
| 40 // simultaneously. If we get an asynchonous request followed by a synchronous | 41 // simultaneously. If we get an asynchonous request followed by a synchronous |
| 41 // request then we have to call this a second time to finish starting the | 42 // request then we have to call this a second time to finish starting the |
| 42 // browser synchronously. | 43 // browser synchronously. |
| 43 if (!g_content_runner.Get().get()) { | 44 if (!g_content_runner.Get().get()) { |
| 44 ContentMainParams params(g_content_main_delegate.Get().get()); | 45 ContentMainParams params(g_content_main_delegate.Get().get()); |
| 45 g_content_runner.Get().reset(ContentMainRunner::Create()); | 46 g_content_runner.Get().reset(ContentMainRunner::Create()); |
| 46 g_content_runner.Get()->Initialize(params); | 47 g_content_runner.Get()->Initialize(params); |
| 47 } | 48 } |
| 48 return g_content_runner.Get()->Run(); | 49 return g_content_runner.Get()->Run(); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void SetContentMainDelegate(ContentMainDelegate* delegate) { | 52 void SetContentMainDelegate(ContentMainDelegate* delegate) { |
| 52 DCHECK(!g_content_main_delegate.Get().get()); | 53 DCHECK(!g_content_main_delegate.Get().get()); |
| 53 g_content_main_delegate.Get().reset(delegate); | 54 g_content_main_delegate.Get().reset(delegate); |
| 54 } | 55 } |
| 55 | 56 |
| 56 bool RegisterContentMain(JNIEnv* env) { | 57 bool RegisterContentMain(JNIEnv* env) { |
| 57 return RegisterNativesImpl(env); | 58 return RegisterNativesImpl(env); |
| 58 } | 59 } |
| 59 | 60 |
| 60 } // namespace content | 61 } // namespace content |
| OLD | NEW |