michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: package org.mozilla.gecko.background.sync.helpers; michael@0: michael@0: import org.mozilla.gecko.sync.repositories.RepositorySession; michael@0: import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionCreationDelegate; michael@0: michael@0: public class DefaultSessionCreationDelegate extends DefaultDelegate implements michael@0: RepositorySessionCreationDelegate { michael@0: michael@0: @Override michael@0: public void onSessionCreateFailed(Exception ex) { michael@0: performNotify("Session creation failed", ex); michael@0: } michael@0: michael@0: @Override michael@0: public void onSessionCreated(RepositorySession session) { michael@0: performNotify("Should not have been created.", null); michael@0: } michael@0: michael@0: @Override michael@0: public RepositorySessionCreationDelegate deferredCreationDelegate() { michael@0: final RepositorySessionCreationDelegate self = this; michael@0: return new RepositorySessionCreationDelegate() { michael@0: michael@0: @Override michael@0: public void onSessionCreated(final RepositorySession session) { michael@0: new Thread(new Runnable() { michael@0: @Override michael@0: public void run() { michael@0: self.onSessionCreated(session); michael@0: } michael@0: }).start(); michael@0: } michael@0: michael@0: @Override michael@0: public void onSessionCreateFailed(final Exception ex) { michael@0: new Thread(new Runnable() { michael@0: @Override michael@0: public void run() { michael@0: self.onSessionCreateFailed(ex); michael@0: } michael@0: }).start(); michael@0: } michael@0: michael@0: @Override michael@0: public RepositorySessionCreationDelegate deferredCreationDelegate() { michael@0: return this; michael@0: } michael@0: }; michael@0: } michael@0: }