Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1286)

Unified Diff: content/public/android/java/src/org/chromium/content/app/ContentApplication.java

Issue 26740005: Let BaseChromiumApplication manage the tracing controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep BaseChromiumApplication (required by native unit tests) Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/app/ContentApplication.java
diff --git a/content/public/android/java/src/org/chromium/content/app/ContentApplication.java b/content/public/android/java/src/org/chromium/content/app/ContentApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..97b6a487bd4b6e55b7aba2495a308d2ca25ab134
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/app/ContentApplication.java
@@ -0,0 +1,65 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.app;
+
+import android.os.Looper;
+import android.os.MessageQueue;
+
+import org.chromium.base.BaseChromiumApplication;
+import org.chromium.content.browser.TracingControllerAndroid;
+
+/**
+ * Basic application functionality that should be shared among all browser applications
+ * based on the content layer.
+ */
+public class ContentApplication extends BaseChromiumApplication {
+ private TracingControllerAndroid mTracingController;
+
+ TracingControllerAndroid getTracingController() {
+ if (mTracingController == null) {
+ mTracingController = new TracingControllerAndroid(this);
+ }
+ return mTracingController;
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ // Delay TracingControllerAndroid.registerReceiver() until the main loop is idle.
+ Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
+ @Override
+ public boolean queueIdle() {
+ // Will retry if the native library has not been initialized.
+ if (!LibraryLoader.isInitialized()) return true;
+
+ try {
+ getTracingController().registerReceiver(ContentApplication.this);
+ } catch (SecurityException e) {
+ // Happens if the process is isolated. Ignore.
+ }
+ // Remove the idle handler.
+ return false;
+ }
+ });
+ }
+
+ /**
+ * For emulated process environment only. On a production device, the application process is
+ * simply killed without calling this method. We don't need to unregister the broadcast
+ * receiver in the latter case.
+ */
+ @Override
+ public void onTerminate() {
+ try {
+ getTracingController().unregisterReceiver(this);
+ } catch (SecurityException e) {
+ // Happens if the process is isolated. Ignore.
+ }
+
+ super.onTerminate();
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698