Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/org/adblockplus/libadblockplus/JniExceptionHandler.java

Issue 6606493159784448: New JNI bindings (Closed)
Patch Set: Removed TODO from AppInfo. Created April 11, 2014, 1:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package org.adblockplus.libadblockplus;
19
20 import java.util.concurrent.LinkedBlockingQueue;
21
22 public final class JniExceptionHandler
23 {
24 private static LogWorker logWorker = null;
25
26 static
27 {
28 logWorker = new LogWorker();
29 final Thread t = new Thread(logWorker);
30 t.setDaemon(true);
31 t.start();
32 }
33
34 public static void logException(final Throwable t)
35 {
36 logWorker.logException(t);
37 }
38
39 private final static class LogWorker implements Runnable
40 {
41 LinkedBlockingQueue<Throwable> exceptionQueue = new LinkedBlockingQueue<Thro wable>();
42
43 private void logException(final Throwable t)
44 {
45 this.exceptionQueue.offer(t);
46 }
47
48 @Override
49 public void run()
50 {
51 for (;;)
52 {
53 try
54 {
55 final Throwable t = this.exceptionQueue.take();
56 // TODO: We need a log callback
57 System.err.println("EXCEPTION: " + t);
58 }
59 catch (final InterruptedException ie)
60 {
61 break;
62 }
63 catch (final Throwable ex)
64 {
65 // TODO: Swallow or log?
66 }
67 }
68 }
69 }
70 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/libadblockplus/FilterEngine.java ('k') | src/org/adblockplus/libadblockplus/JsEngine.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld