Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | package org.mozilla.gecko.sync.repositories.delegates; |
michael@0 | 6 | |
michael@0 | 7 | import java.util.concurrent.ExecutorService; |
michael@0 | 8 | |
michael@0 | 9 | import org.mozilla.gecko.sync.repositories.RepositorySession; |
michael@0 | 10 | import org.mozilla.gecko.sync.repositories.RepositorySessionBundle; |
michael@0 | 11 | |
michael@0 | 12 | public class DeferredRepositorySessionFinishDelegate implements |
michael@0 | 13 | RepositorySessionFinishDelegate { |
michael@0 | 14 | protected final ExecutorService executor; |
michael@0 | 15 | protected final RepositorySessionFinishDelegate inner; |
michael@0 | 16 | |
michael@0 | 17 | public DeferredRepositorySessionFinishDelegate(RepositorySessionFinishDelegate inner, |
michael@0 | 18 | ExecutorService executor) { |
michael@0 | 19 | this.executor = executor; |
michael@0 | 20 | this.inner = inner; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | @Override |
michael@0 | 24 | public void onFinishSucceeded(final RepositorySession session, |
michael@0 | 25 | final RepositorySessionBundle bundle) { |
michael@0 | 26 | executor.execute(new Runnable() { |
michael@0 | 27 | @Override |
michael@0 | 28 | public void run() { |
michael@0 | 29 | inner.onFinishSucceeded(session, bundle); |
michael@0 | 30 | } |
michael@0 | 31 | }); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | @Override |
michael@0 | 35 | public void onFinishFailed(final Exception ex) { |
michael@0 | 36 | executor.execute(new Runnable() { |
michael@0 | 37 | @Override |
michael@0 | 38 | public void run() { |
michael@0 | 39 | inner.onFinishFailed(ex); |
michael@0 | 40 | } |
michael@0 | 41 | }); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | @Override |
michael@0 | 45 | public RepositorySessionFinishDelegate deferredFinishDelegate(ExecutorService newExecutor) { |
michael@0 | 46 | if (newExecutor == executor) { |
michael@0 | 47 | return this; |
michael@0 | 48 | } |
michael@0 | 49 | throw new IllegalArgumentException("Can't re-defer this delegate."); |
michael@0 | 50 | } |
michael@0 | 51 | } |