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 | public class DeferredRepositorySessionStoreDelegate implements |
michael@0 | 10 | RepositorySessionStoreDelegate { |
michael@0 | 11 | protected final RepositorySessionStoreDelegate inner; |
michael@0 | 12 | protected final ExecutorService executor; |
michael@0 | 13 | |
michael@0 | 14 | public DeferredRepositorySessionStoreDelegate( |
michael@0 | 15 | RepositorySessionStoreDelegate inner, ExecutorService executor) { |
michael@0 | 16 | this.inner = inner; |
michael@0 | 17 | this.executor = executor; |
michael@0 | 18 | } |
michael@0 | 19 | |
michael@0 | 20 | @Override |
michael@0 | 21 | public void onRecordStoreSucceeded(final String guid) { |
michael@0 | 22 | executor.execute(new Runnable() { |
michael@0 | 23 | @Override |
michael@0 | 24 | public void run() { |
michael@0 | 25 | inner.onRecordStoreSucceeded(guid); |
michael@0 | 26 | } |
michael@0 | 27 | }); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | @Override |
michael@0 | 31 | public void onRecordStoreFailed(final Exception ex, final String guid) { |
michael@0 | 32 | executor.execute(new Runnable() { |
michael@0 | 33 | @Override |
michael@0 | 34 | public void run() { |
michael@0 | 35 | inner.onRecordStoreFailed(ex, guid); |
michael@0 | 36 | } |
michael@0 | 37 | }); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | @Override |
michael@0 | 41 | public RepositorySessionStoreDelegate deferredStoreDelegate(ExecutorService newExecutor) { |
michael@0 | 42 | if (newExecutor == executor) { |
michael@0 | 43 | return this; |
michael@0 | 44 | } |
michael@0 | 45 | throw new IllegalArgumentException("Can't re-defer this delegate."); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | @Override |
michael@0 | 49 | public void onStoreCompleted(final long storeEnd) { |
michael@0 | 50 | executor.execute(new Runnable() { |
michael@0 | 51 | @Override |
michael@0 | 52 | public void run() { |
michael@0 | 53 | inner.onStoreCompleted(storeEnd); |
michael@0 | 54 | } |
michael@0 | 55 | }); |
michael@0 | 56 | } |
michael@0 | 57 | } |