| 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.net.impl; | 5 package org.chromium.net.impl; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Handler; | 8 import android.os.Handler; |
| 9 import android.os.Looper; | 9 import android.os.Looper; |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 sInitStarted = true; | 42 sInitStarted = true; |
| 43 ContextUtils.initApplicationContext(applicationContext); | 43 ContextUtils.initApplicationContext(applicationContext); |
| 44 if (builder.libraryLoader() != null) { | 44 if (builder.libraryLoader() != null) { |
| 45 builder.libraryLoader().loadLibrary(LIBRARY_NAME); | 45 builder.libraryLoader().loadLibrary(LIBRARY_NAME); |
| 46 } else { | 46 } else { |
| 47 System.loadLibrary(LIBRARY_NAME); | 47 System.loadLibrary(LIBRARY_NAME); |
| 48 } | 48 } |
| 49 ContextUtils.initApplicationContextForNative(); | 49 ContextUtils.initApplicationContextForNative(); |
| 50 if (!ImplVersion.CRONET_VERSION.equals(nativeGetCronetVersion())) { | 50 String implVersion = ImplVersion.getCronetVersion(); |
| 51 if (!implVersion.equals(nativeGetCronetVersion())) { |
| 51 throw new RuntimeException(String.format("Expected Cronet versio
n number %s, " | 52 throw new RuntimeException(String.format("Expected Cronet versio
n number %s, " |
| 52 + "actual version number %s.", | 53 + "actual version number %s.", |
| 53 ImplVersion.CRONET_VERSION, nativeGetCronetVersion())); | 54 implVersion, nativeGetCronetVersion())); |
| 54 } | 55 } |
| 55 Log.i(TAG, "Cronet version: %s, arch: %s", ImplVersion.CRONET_VERSIO
N, | 56 Log.i(TAG, "Cronet version: %s, arch: %s", implVersion, System.getPr
operty("os.arch")); |
| 56 System.getProperty("os.arch")); | |
| 57 // Init native Chromium CronetEngine on Main UI thread. | 57 // Init native Chromium CronetEngine on Main UI thread. |
| 58 Runnable task = new Runnable() { | 58 Runnable task = new Runnable() { |
| 59 @Override | 59 @Override |
| 60 public void run() { | 60 public void run() { |
| 61 ensureInitializedOnMainThread(applicationContext); | 61 ensureInitializedOnMainThread(applicationContext); |
| 62 } | 62 } |
| 63 }; | 63 }; |
| 64 // Run task immediately or post it to the UI thread. | 64 // Run task immediately or post it to the UI thread. |
| 65 if (Looper.getMainLooper() == Looper.myLooper()) { | 65 if (Looper.getMainLooper() == Looper.myLooper()) { |
| 66 task.run(); | 66 task.run(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 95 // the undesired initial network change observer notification, which | 95 // the undesired initial network change observer notification, which |
| 96 // will cause active requests to fail with ERR_NETWORK_CHANGED. | 96 // will cause active requests to fail with ERR_NETWORK_CHANGED. |
| 97 nativeCronetInitOnMainThread(); | 97 nativeCronetInitOnMainThread(); |
| 98 sMainThreadInitDone = true; | 98 sMainThreadInitDone = true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Native methods are implemented in cronet_library_loader.cc. | 101 // Native methods are implemented in cronet_library_loader.cc. |
| 102 private static native void nativeCronetInitOnMainThread(); | 102 private static native void nativeCronetInitOnMainThread(); |
| 103 private static native String nativeGetCronetVersion(); | 103 private static native String nativeGetCronetVersion(); |
| 104 } | 104 } |
| OLD | NEW |