OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.blimp; | 5 package org.chromium.blimp; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.os.Handler; | 8 import android.os.Handler; |
9 | 9 |
| 10 import org.chromium.base.ContextUtils; |
10 import org.chromium.base.ObserverList; | 11 import org.chromium.base.ObserverList; |
11 import org.chromium.base.ResourceExtractor; | 12 import org.chromium.base.ResourceExtractor; |
12 import org.chromium.base.ThreadUtils; | 13 import org.chromium.base.ThreadUtils; |
13 import org.chromium.base.annotations.JNINamespace; | 14 import org.chromium.base.annotations.JNINamespace; |
14 import org.chromium.base.library_loader.LibraryLoader; | 15 import org.chromium.base.library_loader.LibraryLoader; |
15 import org.chromium.base.library_loader.LibraryProcessType; | 16 import org.chromium.base.library_loader.LibraryProcessType; |
16 import org.chromium.base.library_loader.ProcessInitException; | 17 import org.chromium.base.library_loader.ProcessInitException; |
17 | 18 |
18 /** | 19 /** |
19 * Asynchronously loads and registers the native libraries associated with Blimp
. | 20 * Asynchronously loads and registers the native libraries associated with Blimp
. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if (sLoadAttempted) return; | 84 if (sLoadAttempted) return; |
84 sLoadAttempted = true; | 85 sLoadAttempted = true; |
85 | 86 |
86 ResourceExtractor extractor = ResourceExtractor.get(context); | 87 ResourceExtractor extractor = ResourceExtractor.get(context); |
87 extractor.startExtractingResources(); | 88 extractor.startExtractingResources(); |
88 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(
context); | 89 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(
context); |
89 | 90 |
90 extractor.addCompletionCallback(new Runnable() { | 91 extractor.addCompletionCallback(new Runnable() { |
91 @Override | 92 @Override |
92 public void run() { | 93 public void run() { |
93 final boolean initResult = nativeInitializeBlimp(context.getAppl
icationContext()); | 94 ContextUtils.initApplicationContext(context.getApplicationContex
t()); |
| 95 final boolean initResult = nativeInitializeBlimp(); |
94 new Handler().post(new Runnable() { | 96 new Handler().post(new Runnable() { |
95 @Override | 97 @Override |
96 public void run() { | 98 public void run() { |
97 // Only run nativeStartBlimp if we properly initialized
native. | 99 // Only run nativeStartBlimp if we properly initialized
native. |
98 boolean startResult = initResult && nativeStartBlimp(); | 100 boolean startResult = initResult && nativeStartBlimp(); |
99 sLibraryLoadResult = new Boolean(startResult); | 101 sLibraryLoadResult = new Boolean(startResult); |
100 | 102 |
101 // Notify any oustanding callers to #startAsync(). | 103 // Notify any oustanding callers to #startAsync(). |
102 notifyCallbacksAndClear(); | 104 notifyCallbacksAndClear(); |
103 } | 105 } |
(...skipping 15 matching lines...) Expand all Loading... |
119 new Handler().post(new Runnable() { | 121 new Handler().post(new Runnable() { |
120 @Override | 122 @Override |
121 public void run() { | 123 public void run() { |
122 ThreadUtils.assertOnUiThread(); | 124 ThreadUtils.assertOnUiThread(); |
123 callback.onStartupComplete(sLibraryLoadResult); | 125 callback.onStartupComplete(sLibraryLoadResult); |
124 } | 126 } |
125 }); | 127 }); |
126 } | 128 } |
127 | 129 |
128 // Native methods. | 130 // Native methods. |
129 private static native boolean nativeInitializeBlimp(Context context); | 131 private static native boolean nativeInitializeBlimp(); |
130 private static native boolean nativeStartBlimp(); | 132 private static native boolean nativeStartBlimp(); |
131 } | 133 } |
OLD | NEW |