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() { |
| 94 ContextUtils.initApplicationContext(context.getApplicationContex
t()); |
93 new Handler().post(new Runnable() { | 95 new Handler().post(new Runnable() { |
94 @Override | 96 @Override |
95 public void run() { | 97 public void run() { |
96 // Only run nativeStartBlimp if we properly initialized
native. | 98 // Only run nativeStartBlimp if we properly initialized
native. |
97 boolean startResult = nativeStartBlimp(); | 99 boolean startResult = nativeStartBlimp(); |
98 sLibraryLoadResult = Boolean.valueOf(startResult); | 100 sLibraryLoadResult = Boolean.valueOf(startResult); |
99 | 101 |
100 // Notify any oustanding callers to #startAsync(). | 102 // Notify any oustanding callers to #startAsync(). |
101 notifyCallbacksAndClear(); | 103 notifyCallbacksAndClear(); |
102 } | 104 } |
(...skipping 17 matching lines...) Expand all Loading... |
120 public void run() { | 122 public void run() { |
121 ThreadUtils.assertOnUiThread(); | 123 ThreadUtils.assertOnUiThread(); |
122 callback.onStartupComplete(sLibraryLoadResult); | 124 callback.onStartupComplete(sLibraryLoadResult); |
123 } | 125 } |
124 }); | 126 }); |
125 } | 127 } |
126 | 128 |
127 // Native methods. | 129 // Native methods. |
128 private static native boolean nativeStartBlimp(); | 130 private static native boolean nativeStartBlimp(); |
129 } | 131 } |
OLD | NEW |