Add hybrid class to hold native delta client

Summary:
Adds hybrid JNI wrapper class that can hold a native delta client.

This class allows Java code in the `devsupport` package to hold onto a native delta client across reloads.
It also takes care of passing `okhttp` response objects to native code, where we build a `std::string` to hold JSON messages coming from Metro, and parse them with `folly::parseJson`.

In a follow-up, we will switch to a streaming-friendly binary format that will make allocating memory for the whole message unnecessary.

Reviewed By: fromcelticpark

Differential Revision: D7845138

fbshipit-source-id: 7a29b30645331addf843097dd0d05c03b3143991
This commit is contained in:
David Aurelio
2018-05-03 08:38:03 -07:00
committed by Facebook Github Bot
parent 4d931d529e
commit 82b8a9221a
5 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
/**
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.bridge;
import java.nio.channels.ReadableByteChannel;
import com.facebook.jni.HybridData;
public class NativeDeltaClient {
static {
ReactBridge.staticInit();
}
// C++ parts
private final HybridData mHybridData = initHybrid();
private native static HybridData initHybrid();
public native void reset();
public native void processDelta(ReadableByteChannel deltaMessage);
}