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