build/mobile/robocop/RobocopUtils.java

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 package org.mozilla.gecko;
     7 import java.util.concurrent.SynchronousQueue;
     8 import java.util.concurrent.TimeUnit;
    10 import android.app.Activity;
    12 public final class RobocopUtils {
    13     private static final int MAX_WAIT_MS = 20000;
    15     private RobocopUtils() {}
    17     public static void runOnUiThreadSync(Activity activity, final Runnable runnable) {
    18         final SynchronousQueue syncQueue = new SynchronousQueue();
    19         activity.runOnUiThread(
    20             new Runnable() {
    21                 public void run() {
    22                     runnable.run();
    23                     try {
    24                         syncQueue.put(new Object());
    25                     } catch (InterruptedException e) {
    26                         FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
    27                     }
    28                 }
    29             });
    30         try {
    31             // Wait for the UiThread code to finish running
    32             if (syncQueue.poll(MAX_WAIT_MS, TimeUnit.MILLISECONDS) == null) {
    33                 FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR,
    34                                        "time-out waiting for UI thread");
    35                 FennecNativeDriver.logAllStackTraces(FennecNativeDriver.LogLevel.ERROR);
    36             }
    37         } catch (InterruptedException e) {
    38             FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
    39         }
    40     }
    41 }

mercurial