summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/android/testshell/DEPS1
-rw-r--r--chrome/android/testshell/javatests/src/org/chromium/chrome/testshell/ChromiumTestShellUrlTest.java28
-rw-r--r--chrome/browser/chrome_browser_main_android.cc3
-rw-r--r--content/browser/android/content_view_render_view.cc7
-rw-r--r--content/shell/android/shell_library_loader.cc6
5 files changed, 38 insertions, 7 deletions
diff --git a/chrome/android/testshell/DEPS b/chrome/android/testshell/DEPS
index 8dd8baf..6931362 100644
--- a/chrome/android/testshell/DEPS
+++ b/chrome/android/testshell/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+chrome/app",
"+chrome/browser",
+ "+content/public/android",
"+content/public/browser/android",
]
diff --git a/chrome/android/testshell/javatests/src/org/chromium/chrome/testshell/ChromiumTestShellUrlTest.java b/chrome/android/testshell/javatests/src/org/chromium/chrome/testshell/ChromiumTestShellUrlTest.java
index 9f44ce9..2a61f6b 100644
--- a/chrome/android/testshell/javatests/src/org/chromium/chrome/testshell/ChromiumTestShellUrlTest.java
+++ b/chrome/android/testshell/javatests/src/org/chromium/chrome/testshell/ChromiumTestShellUrlTest.java
@@ -7,6 +7,7 @@ package org.chromium.chrome.testshell;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.test.util.Feature;
+import org.chromium.content.browser.ContentViewRenderView;
public class ChromiumTestShellUrlTest extends ChromiumTestShellTestBase {
// URL used for base tests.
@@ -21,4 +22,31 @@ public class ChromiumTestShellUrlTest extends ChromiumTestShellTestBase {
// Make sure the activity was created as expected.
assertNotNull(activity);
}
+
+ /**
+ * Tests that creating an extra ContentViewRenderView does not cause an assert because we would
+ * initialize the compositor twice http://crbug.com/162312
+ */
+ @SmallTest
+ @Feature({"Main"})
+ public void testCompositorInit() throws Exception {
+ // Start the ChromiumTestShell, this loads the native library and create an instance of
+ // ContentViewRenderView.
+ final ChromiumTestShellActivity activity = launchChromiumTestShellWithUrl(URL);
+ waitForActiveShellToBeDoneLoading();
+
+ // Now create a new ContentViewRenderView, it should not assert.
+ try {
+ runTestOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ContentViewRenderView contentViewRenderView =
+ new ContentViewRenderView(getInstrumentation().getTargetContext());
+ contentViewRenderView.setCurrentContentView(activity.getActiveContentView());
+ }
+ });
+ } catch (Throwable e) {
+ fail("Could not create a ContentViewRenderView: " + e);
+ }
+ }
} \ No newline at end of file
diff --git a/chrome/browser/chrome_browser_main_android.cc b/chrome/browser/chrome_browser_main_android.cc
index 4522b54..041bd37 100644
--- a/chrome/browser/chrome_browser_main_android.cc
+++ b/chrome/browser/chrome_browser_main_android.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chrome_browser_main_android.h"
#include "chrome/app/breakpad_linux.h"
+#include "content/public/browser/android/compositor.h"
#include "content/public/common/main_function_params.h"
#include "net/android/network_change_notifier_factory_android.h"
#include "net/base/network_change_notifier.h"
@@ -32,6 +33,8 @@ void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() {
net::NetworkChangeNotifier::SetFactory(
new net::NetworkChangeNotifierFactoryAndroid());
+ content::Compositor::Initialize();
+
// Chrome on Android does not use default MessageLoop. It has its own
// Android specific MessageLoop.
DCHECK(!main_message_loop_.get());
diff --git a/content/browser/android/content_view_render_view.cc b/content/browser/android/content_view_render_view.cc
index 2e040c5..9f780fd 100644
--- a/content/browser/android/content_view_render_view.cc
+++ b/content/browser/android/content_view_render_view.cc
@@ -89,11 +89,8 @@ void ContentViewRenderView::ScheduleComposite() {
}
void ContentViewRenderView::InitCompositor() {
- if (compositor_.get())
- return;
-
- Compositor::Initialize();
- compositor_.reset(Compositor::Create(this));
+ if (!compositor_.get())
+ compositor_.reset(Compositor::Create(this));
}
void ContentViewRenderView::Composite() {
diff --git a/content/shell/android/shell_library_loader.cc b/content/shell/android/shell_library_loader.cc
index 33414c6..88262c9 100644
--- a/content/shell/android/shell_library_loader.cc
+++ b/content/shell/android/shell_library_loader.cc
@@ -9,6 +9,7 @@
#include "base/android/jni_registrar.h"
#include "content/public/app/android_library_loader_hooks.h"
#include "content/public/app/content_main.h"
+#include "content/public/browser/android/compositor.h"
#include "content/shell/android/shell_manager.h"
#include "content/shell/shell.h"
#include "content/shell/shell_main_delegate.h"
@@ -22,9 +23,8 @@ static base::android::RegistrationMethod kRegistrationMethods[] = {
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
base::android::InitVM(vm);
JNIEnv* env = base::android::AttachCurrentThread();
- if (!content::RegisterLibraryLoaderEntryHook(env)) {
+ if (!content::RegisterLibraryLoaderEntryHook(env))
return -1;
- }
// To be called only from the UI thread. If loading the library is done on
// a separate thread, this should be moved elsewhere.
@@ -32,6 +32,8 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
arraysize(kRegistrationMethods)))
return -1;
+ content::Compositor::Initialize();
+
content::SetContentMainDelegate(new content::ShellMainDelegate());
return JNI_VERSION_1_4;