Chromium Code Reviews| Index: mojo/android/system/src/org/chromium/mojo/system/impl/CoreImpl.java |
| diff --git a/mojo/android/system/src/org/chromium/mojo/system/impl/CoreImpl.java b/mojo/android/system/src/org/chromium/mojo/system/impl/CoreImpl.java |
| index 19b2d29fabb61c061968ab41baa1349eead62091..c0117d4a7f9c2b0f43bb41628bfadd5e109538d4 100644 |
| --- a/mojo/android/system/src/org/chromium/mojo/system/impl/CoreImpl.java |
| +++ b/mojo/android/system/src/org/chromium/mojo/system/impl/CoreImpl.java |
| @@ -16,6 +16,7 @@ import org.chromium.mojo.system.MessagePipeHandle; |
| import org.chromium.mojo.system.MojoException; |
| import org.chromium.mojo.system.MojoResult; |
| import org.chromium.mojo.system.Pair; |
| +import org.chromium.mojo.system.RunLoop; |
| import org.chromium.mojo.system.SharedBufferHandle; |
| import org.chromium.mojo.system.SharedBufferHandle.DuplicateOptions; |
| import org.chromium.mojo.system.SharedBufferHandle.MapFlags; |
| @@ -55,6 +56,11 @@ public class CoreImpl implements Core, AsyncWaiter { |
| private static class LazyHolder { private static final Core INSTANCE = new CoreImpl(); } |
| /** |
| + * The run loop for the current thread. |
| + */ |
| + private ThreadLocal<BaseRunLoop> mCurrentRunLoop = new ThreadLocal<BaseRunLoop>(); |
| + |
| + /** |
| * @return the instance. |
| */ |
| public static Core getInstance() { |
| @@ -206,6 +212,31 @@ public class CoreImpl implements Core, AsyncWaiter { |
| } |
| /** |
| + * @see Core#createDefaultRunLoop() |
| + */ |
| + @Override |
| + public RunLoop createDefaultRunLoop() { |
| + if (mCurrentRunLoop.get() != null) { |
| + throw new MojoException(MojoResult.FAILED_PRECONDITION); |
| + } |
| + BaseRunLoop runLoop = new BaseRunLoop(this); |
| + mCurrentRunLoop.set(runLoop); |
| + return runLoop; |
| + } |
| + |
| + /** |
| + * @see Core#getCurrentRunLoop() |
| + */ |
| + @Override |
| + public RunLoop getCurrentRunLoop() { |
| + return mCurrentRunLoop.get(); |
| + } |
| + |
| + void releaseRunLoop() { |
|
qsr
2015/02/10 11:58:18
I would rename this: clearCurrentRunLoop
qsr
2015/02/10 11:58:18
Can you add some comment here. Thanks.
etiennej
2015/02/10 14:32:04
Done.
etiennej
2015/02/10 14:32:04
Done.
|
| + mCurrentRunLoop.remove(); |
| + } |
| + |
| + /** |
| * @see AsyncWaiter#asyncWait(Handle, Core.HandleSignals, long, Callback) |
| */ |
| @Override |