Cronet library for desktop platforms

1,087 views
Skip to first unread message

Marshall Greenblatt

unread,
Apr 24, 2017, 4:15:48 PM4/24/17
to net-dev
Hi All,

Are there any plans currently to support Cronet [1] as a stand-alone library for desktop platforms (Linux, Windows, macOS) in addition to the already supported mobile platforms (Android, iOS)?

Thanks,
Marshall

Misha Efimov

unread,
Apr 25, 2017, 10:56:27 AM4/25/17
to Marshall Greenblatt, net-dev
Hi Marshall,

Currently Cronet only exposes API specific to mobile platforms (Java, Objective C). 
We are working on public C API that could be supported on desktop platforms, however our primary focus remains on mobile.

thanks,
-m

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+unsubscribe@chromium.org.
To post to this group, send email to net...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CAFW9UJ-0t765%3DuOzfyC8pndYB37Z9KcHanJPbkP%3DfpjNYQwE4g%40mail.gmail.com.

chan...@google.com

unread,
Aug 1, 2019, 5:49:11 PM8/1/19
to net-dev, magree...@gmail.com
On Tuesday, April 25, 2017 at 10:56:27 AM UTC-4, Misha Efimov wrote:
> Hi Marshall,
>
>
> Currently Cronet only exposes API specific to mobile platforms (Java, Objective C). 
> We are working on public C API that could be supported on desktop platforms, however our primary focus remains on mobile.
>
>
> thanks,
> -m
>
>
> On Mon, Apr 24, 2017 at 4:15 PM, Marshall Greenblatt <magree...@gmail.com> wrote:
>
> Hi All,
>
>
> Are there any plans currently to support Cronet [1] as a stand-alone library for desktop platforms (Linux, Windows, macOS) in addition to the already supported mobile platforms (Android, iOS)?
>
>
> Thanks,
> Marshall
>
>
> [1] https://chromium.googlesource.com/chromium/src/+/lkgr/components/cronet/
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "net-dev" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to net...@chromium.org.
I've been researching a way to use Cronet for plain Java desktop applications. Is a standalone Java library still not yet available?

I thought I could somehow build such a library from https://chromium.googlesource.com/chromium/src/+/HEAD/components/cronet/build_instructions.md, which has the section "Desktop builds (targets the current OS)". But all I get is some shared .so libraries, and I came to my own conclusion that there is no Java library I can build for desktop applications. Did I understand it right?

Is there any way I can easily use Cronet to do "new CronetEngine()" and just start using it?

Caleb Raitto

unread,
Aug 1, 2019, 6:20:48 PM8/1/19
to chan...@google.com, net-dev, magree...@gmail.com
Correct, the Java API is only for Android -- it references android.* packages, which aren't in desktop Java. 

To target desktop, you'd have to use the Cronet native C API (you could call this from a Java desktop app via JNI -- it can also be used directly from C++). 

We don't provide official support for Cronet on desktop today, so you'd have to build the library from the Chromium repository, which it sounds like you've already done.

A sample for the native C API can be found in the Chromium repo: https://cs.chromium.org/chromium/src/components/cronet/native/sample/ -- you can build it (assuming you used out/Cronet as your output directory) with ninja -C out/Cronet cronet_sample -- the sample also has unit tests in its test/ subdirectory you can build with ninja -C out/Cronet cronet_sample_test (both of those targets are defined in components/cronet/BUILD.gn).

That should give you an environment to try out the API.

The API is intentionally similar to the Java / Android Cronet API, and is mostly defined in an IDL file (using Chromium's mojo IPC language -- however, note that Cronet native is in-process) that's transformed into C headers via a generator script. The main entry header, cronet_c.h, defines a few extra functions that aren't in the IDL. IDL interfaces with the [Abstract] keyword are implemented by the app.

For example, an IDL interface like UrlRequest makes methods like:

Cronet_UrlRequest_Destroy()
Cronet_UrlRequest_InitWithParams()
Cronet_UrlRequest_Read()
...

Similarly, structures generate methods like this (we don't share anything but void pointers across the library boundary -- the headers have function definitions only):

Cronet_UrlRequestParams_http_method_set()
Cronet_UrlRequestParams_request_headers_add()
Cronet_UrlRequestParams_request_headers_size()
Cronet_UrlRequestParams_request_headers_at()
Cronet_UrlRequestParams_request_headers_clear()
 
-Caleb



To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/66ca382d-0bcf-4576-b1fd-81765fc97296%40chromium.org.

王坤

unread,
Mar 22, 2021, 9:12:22 PM3/22/21
to net-dev, cara...@chromium.org, net-dev, magree...@gmail.com, chan...@google.com
Maybe now it's time to try Cronet C API with Flutter Desktop or Compose for Desktop

闫辉

unread,
May 18, 2021, 1:14:42 AM5/18/21
to net-dev, magree...@gmail.com
same question ~
Reply all
Reply to author
Forward
0 new messages