forked from PolymerLabs/arcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pipe devToolsProxy into stores (PolymerLabs#6037)
* Pipe devToolsProxy into stores * Fix tests. * Merge conflict resolution Co-authored-by: Sarah Heimlich <[email protected]>
- Loading branch information
Showing
18 changed files
with
92 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
package arcs.android.storage.service | ||
|
||
import arcs.android.storage.toProto | ||
import arcs.core.storage.DevToolsProxy | ||
import arcs.core.storage.ProxyMessage | ||
|
||
/** | ||
* Implementation of [IDevToolsProxy] to allow communication between the [StorageService] and | ||
* [DevToolsService] | ||
*/ | ||
class DevToolsProxyImpl : IDevToolsProxy.Stub() { | ||
private val onBindingContextProxyMessageCallbacks = mutableMapOf<Int, IStorageServiceCallback>() | ||
private var bindingContextCallbackCounter = 0 | ||
class DevToolsProxyImpl : IDevToolsProxy.Stub(), DevToolsProxy { | ||
private val onRefModeStoreProxyMessageCallbacks = mutableMapOf<Int, IStorageServiceCallback>() | ||
private var refModeStoreCallbackCounter = 0 | ||
|
||
/** | ||
* TODO: (sarahheimlich) remove once we dive into stores (b/162955831) | ||
* | ||
* Execute the callbacks to be called with the [BindingContext] receives a [ProxyMessage] | ||
*/ | ||
fun onBindingContextProxyMessage(proxyMessage: ByteArray) { | ||
onBindingContextProxyMessageCallbacks.forEach { (_, callback) -> | ||
callback.onProxyMessage(proxyMessage) | ||
override fun onRefModeStoreProxyMessage(proxyMessage: ProxyMessage<*, *, *>) { | ||
onRefModeStoreProxyMessageCallbacks.forEach { (_, callback) -> | ||
callback.onProxyMessage(proxyMessage.toProto().toByteArray()) | ||
} | ||
} | ||
|
||
override fun registerBindingContextProxyMessageCallback( | ||
override fun registerRefModeStoreProxyMessageCallback( | ||
callback: IStorageServiceCallback | ||
): Int { | ||
bindingContextCallbackCounter++ | ||
onBindingContextProxyMessageCallbacks.put(bindingContextCallbackCounter, callback) | ||
return bindingContextCallbackCounter | ||
refModeStoreCallbackCounter++ | ||
onRefModeStoreProxyMessageCallbacks.put(refModeStoreCallbackCounter, callback) | ||
return refModeStoreCallbackCounter | ||
} | ||
|
||
override fun deRegisterBindingContextProxyMessageCallback(callbackToken: Int) { | ||
onBindingContextProxyMessageCallbacks.remove(callbackToken) | ||
override fun deRegisterRefModeStoreProxyMessageCallback(callbackToken: Int) { | ||
onRefModeStoreProxyMessageCallbacks.remove(callbackToken) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package arcs.core.storage | ||
|
||
/** | ||
* Exposed API to communicate between an [ActiveStore] and [DevToolsService]. | ||
*/ | ||
interface DevToolsProxy { | ||
|
||
/** | ||
* Function to call when a [ReferenceModeStore] receives a [ProxyMessage]. | ||
*/ | ||
fun onRefModeStoreProxyMessage(proxyMessage: ProxyMessage<*, *, *>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,8 @@ class BindingContextTest { | |
StoreOptions( | ||
storageKey, | ||
CountType() | ||
) | ||
), | ||
null | ||
) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.