Add flag to disable mmap in all sql connection in work build
Work Chrome runs in environment without a proper mmap support. Disable it for all work chrome. BUG=554269 Review URL: https://codereview.chromium.org/1637683003 Cr-Commit-Position: refs/heads/master@{#372179}
This commit is contained in:
chrome
android
java
src
org
chromium
chrome
browser
android
sql
@ -46,6 +46,13 @@ public class ChromeVersionInfo {
|
||||
|| ChromeVersionConstants.CHANNEL == ChromeVersionConstants.CHANNEL_WORK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether this build is a work build.
|
||||
*/
|
||||
public static boolean isWorkBuild() {
|
||||
return ChromeVersionConstants.CHANNEL == ChromeVersionConstants.CHANNEL_WORK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether this is an official (i.e. Google Chrome) build.
|
||||
*/
|
||||
|
@ -27,10 +27,12 @@ import org.chromium.base.library_loader.ProcessInitException;
|
||||
import org.chromium.chrome.browser.ChromeApplication;
|
||||
import org.chromium.chrome.browser.ChromeStrictMode;
|
||||
import org.chromium.chrome.browser.ChromeSwitches;
|
||||
import org.chromium.chrome.browser.ChromeVersionInfo;
|
||||
import org.chromium.chrome.browser.FileProviderHelper;
|
||||
import org.chromium.chrome.browser.device.DeviceClassManager;
|
||||
import org.chromium.chrome.browser.services.GoogleServicesManager;
|
||||
import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelImpl;
|
||||
import org.chromium.chrome.browser.util.FeatureUtilities;
|
||||
import org.chromium.chrome.browser.webapps.ActivityAssigner;
|
||||
import org.chromium.content.app.ContentApplication;
|
||||
import org.chromium.content.browser.BrowserStartupController;
|
||||
@ -185,6 +187,12 @@ public class ChromeBrowserInitializer {
|
||||
throws ProcessInitException {
|
||||
assert ThreadUtils.runningOnUiThread() : "Tried to start the browser on the wrong thread";
|
||||
|
||||
// This has to be called to stop mmap in sql connection before any db initialized.
|
||||
// It applies to Work Chrome only as mmap doesn't work properly.
|
||||
if (ChromeVersionInfo.isWorkBuild()) {
|
||||
FeatureUtilities.nativeSetSqlMmapDisabledByDefault();
|
||||
}
|
||||
|
||||
final LinkedList<Runnable> initQueue = new LinkedList<Runnable>();
|
||||
|
||||
abstract class NativeInitTask implements Runnable {
|
||||
|
@ -173,4 +173,5 @@ public class FeatureUtilities {
|
||||
|
||||
private static native void nativeSetDocumentModeEnabled(boolean enabled);
|
||||
private static native void nativeSetCustomTabVisible(boolean visible);
|
||||
public static native void nativeSetSqlMmapDisabledByDefault();
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include "jni/FeatureUtilities_jni.h"
|
||||
|
||||
#include "sql/connection.h"
|
||||
|
||||
namespace {
|
||||
bool document_mode_enabled = false;
|
||||
bool custom_tab_visible = false;
|
||||
@ -39,6 +41,11 @@ static void SetCustomTabVisible(JNIEnv* env,
|
||||
custom_tab_visible = visible;
|
||||
}
|
||||
|
||||
static void SetSqlMmapDisabledByDefault(JNIEnv* env,
|
||||
const JavaParamRef<jclass>& clazz) {
|
||||
sql::Connection::set_mmap_disabled_by_default();
|
||||
}
|
||||
|
||||
bool RegisterFeatureUtilities(JNIEnv* env) {
|
||||
return RegisterNativesImpl(env);
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ namespace {
|
||||
// TODO(shess): Better story on this. http://crbug.com/56559
|
||||
const int kBusyTimeoutSeconds = 1;
|
||||
|
||||
bool g_mmap_disabled_default = false;
|
||||
|
||||
class ScopedBusyTimeout {
|
||||
public:
|
||||
explicit ScopedBusyTimeout(sqlite3* db)
|
||||
@ -254,6 +256,12 @@ bool Connection::ShouldIgnoreSqliteCompileError(int error) {
|
||||
basic_error == SQLITE_CORRUPT;
|
||||
}
|
||||
|
||||
// static
|
||||
void Connection::set_mmap_disabled_by_default() {
|
||||
g_mmap_disabled_default = true;
|
||||
}
|
||||
|
||||
|
||||
void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) {
|
||||
AssertIOAllowed();
|
||||
|
||||
@ -339,7 +347,7 @@ Connection::Connection()
|
||||
needs_rollback_(false),
|
||||
in_memory_(false),
|
||||
poisoned_(false),
|
||||
mmap_disabled_(false),
|
||||
mmap_disabled_(g_mmap_disabled_default),
|
||||
mmap_enabled_(false),
|
||||
total_changes_at_last_release_(0),
|
||||
stats_histogram_(NULL),
|
||||
|
@ -149,9 +149,12 @@ class SQL_EXPORT Connection {
|
||||
// other platforms.
|
||||
void set_restrict_to_user() { restrict_to_user_ = true; }
|
||||
|
||||
// Call to opt out of memory-mapped file I/O.
|
||||
// Call to opt out of memory-mapped file I/O on per connection basis.
|
||||
void set_mmap_disabled() { mmap_disabled_ = true; }
|
||||
|
||||
// Call to opt out of memory-mapped file I/O on all connections.
|
||||
static void set_mmap_disabled_by_default();
|
||||
|
||||
// Set an error-handling callback. On errors, the error number (and
|
||||
// statement, if available) will be passed to the callback.
|
||||
//
|
||||
|
Reference in New Issue
Block a user