Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / app / android / library_loader_hooks.cc
blob725491d67fe07d5a67b3bb537178cda83e1b2c7a
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/public/app/android_library_loader_hooks.h"
7 #include "base/android/base_jni_registrar.h"
8 #include "base/android/jni_android.h"
9 #include "base/android/jni_registrar.h"
10 #include "base/android/jni_string.h"
11 #include "base/at_exit.h"
12 #include "base/base_switches.h"
13 #include "base/command_line.h"
14 #include "base/debug/trace_event.h"
15 #include "base/files/file_path.h"
16 #include "base/logging.h"
17 #include "base/strings/string_util.h"
18 #include "base/tracked_objects.h"
19 #include "content/app/android/app_jni_registrar.h"
20 #include "content/browser/android/browser_jni_registrar.h"
21 #include "content/child/android/child_jni_registrar.h"
22 #include "content/common/android/command_line.h"
23 #include "content/common/android/common_jni_registrar.h"
24 #include "content/public/common/content_switches.h"
25 #include "content/public/common/result_codes.h"
26 #include "jni/LibraryLoader_jni.h"
27 #include "media/base/android/media_jni_registrar.h"
28 #include "net/android/net_jni_registrar.h"
29 #include "ui/android/ui_jni_registrar.h"
30 #include "ui/gl/android/gl_jni_registrar.h"
31 #include "ui/shell_dialogs/android/shell_dialogs_jni_registrar.h"
33 namespace {
34 base::AtExitManager* g_at_exit_manager = NULL;
37 namespace content {
39 static jint LibraryLoaded(JNIEnv* env, jclass clazz,
40 jobjectArray init_command_line) {
41 InitNativeCommandLineFromJavaArray(env, init_command_line);
43 CommandLine* command_line = CommandLine::ForCurrentProcess();
45 if (command_line->HasSwitch(switches::kTraceStartup)) {
46 base::debug::CategoryFilter category_filter(
47 command_line->GetSwitchValueASCII(switches::kTraceStartup));
48 base::debug::TraceLog::GetInstance()->SetEnabled(category_filter,
49 base::debug::TraceLog::RECORD_UNTIL_FULL);
52 // Can only use event tracing after setting up the command line.
53 TRACE_EVENT0("jni", "JNI_OnLoad continuation");
55 // Note: because logging is setup here right after copying the command line
56 // array from java to native up top of this method, any code that adds the
57 // --enable-dcheck switch must do so on the Java side.
58 logging::LoggingSettings settings;
59 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
60 settings.dcheck_state =
61 command_line->HasSwitch(switches::kEnableDCHECK) ?
62 logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS :
63 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
64 logging::InitLogging(settings);
65 // To view log output with IDs and timestamps use "adb logcat -v threadtime".
66 logging::SetLogItems(false, // Process ID
67 false, // Thread ID
68 false, // Timestamp
69 false); // Tick count
70 VLOG(0) << "Chromium logging enabled: level = " << logging::GetMinLogLevel()
71 << ", default verbosity = " << logging::GetVlogVerbosity();
73 if (!base::android::RegisterJni(env))
74 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
76 if (!net::android::RegisterJni(env))
77 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
79 if (!ui::android::RegisterJni(env))
80 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
82 if (!ui::gl::android::RegisterJni(env))
83 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
85 if (!ui::shell_dialogs::RegisterJni(env))
86 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
88 if (!content::android::RegisterChildJni(env))
89 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
91 if (!content::android::RegisterCommonJni(env))
92 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
94 if (!content::android::RegisterBrowserJni(env))
95 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
97 if (!content::android::RegisterAppJni(env))
98 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
100 if (!media::RegisterJni(env))
101 return RESULT_CODE_FAILED_TO_REGISTER_JNI;
103 return 0;
106 void LibraryLoaderExitHook() {
107 if (g_at_exit_manager) {
108 delete g_at_exit_manager;
109 g_at_exit_manager = NULL;
113 bool RegisterLibraryLoaderEntryHook(JNIEnv* env) {
114 // We need the AtExitManager to be created at the very beginning.
115 g_at_exit_manager = new base::AtExitManager();
117 return RegisterNativesImpl(env);
120 } // namespace content