Get a NetworkContext object to call url_request_context()

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Get a NetworkContext object to call url_request_context()

Postby user6294 » Thu Jul 23, 2020 5:59 pm

Hi,

CEF 79.x, I need to get hold of the appropriate NetworkContext object, invoke url_request_context() to get a URLRequestContext so
that I can ask it for a ->http_transaction_factory()->GetSession() to pass into HttpNetworkTransaction c'tor, similar to the NetworkContext object
in the debug output below when I run cefclient.exe

This is required in our codebase for tunnelling RTMP protocol over HTTP.

Thank You

00000005 23:40:24.124 [16288] [6132] 229 ProfileNetworkContextService::CreateNetworkContext()
00000006 23:40:24.124 [16288] [6132] 242 GetNetworkService() : g_network_service_remote = 0x0000000000000000
00000007 23:40:24.124 [16288] [6132] 270 GetNetworkService() : out-of-process network-service
00000008 23:40:24.125 [16288] [6132] 214 Launch()
00000009 23:40:24.130 [16288] [6132] 242 GetNetworkService() : g_network_service_remote = 0x0000000004036130
00000010 23:40:24.225 [16288] [6132] 242 GetNetworkService() : g_network_service_remote = 0x0000000004036130
00000011 23:40:24.589 [11528] [10808] 354 this = 0x0000000008114220 NetworkContext::NetworkContext() : network_service = 0x00000000080E5C20
00000012 23:40:24.594 [11528] [10808] 369 URLRequestContextBuilder::Build()
00000013 23:40:24.594 [11528] [10808] 62 0x000000000815D660 = URLRequestContext::URLRequestContext()
00000014 23:40:24.606 [11528] [10808] 73 0x000000000815B250 = URLLoaderFactory::URLLoaderFactory()
00000015 23:40:24.606 [11528] [10808] NetworkContext::url_request_context() : this = 0x0000000008114220
00000016 23:40:24.606 [11528] [10808] 354 this = 0x0000000008169710 NetworkContext::NetworkContext() : network_service = 0x00000000080E5C20
00000017 23:40:24.607 [11528] [10808] 369 URLRequestContextBuilder::Build()
00000018 23:40:24.607 [11528] [10808] 62 0x000000000816B060 = URLRequestContext::URLRequestContext()
00000019 23:40:24.607 [11528] [10808] 73 0x0000000008171350 = URLLoaderFactory::URLLoaderFactory()
00000020 23:40:24.609 [11528] [10808] 124 URLRequestContext::CreateRequest() : url http://proxypac.abc.net/
00000021 23:40:24.610 [11528] [10808] NetworkContext::url_request_context() : this = 0x0000000008114220
user6294
Mentor
 
Posts: 83
Joined: Sun Mar 18, 2018 6:57 pm

Re: Get a NetworkContext object to call url_request_context(

Postby magreenblatt » Thu Jul 23, 2020 6:52 pm

All network code has moved to a separate process. See https://bitbucket.org/chromiumembedded/ ... orkservice
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Get a NetworkContext object to call url_request_context(

Postby user6294 » Fri Jul 24, 2020 12:16 pm

Hi Marshall,

Yes, I am reading 2622 network service changes CEF documentation.

So, our application had some code which in 58.x used the network stack directly, by obtaining a NetworkContext and working at the HttpNetworkTransaction and Session level. Obviously we can't do that now in 79.x because of the Network Stack is now hosted in a Network Service in a separate process and accessed via the new Mojo IPC interface.

Are there any examples of how to do this in CEF that I can play with.

I am reading documentation like Life of a URLRequest, The Network Service and Mojo etc.

Many Thanks
user6294
Mentor
 
Posts: 83
Joined: Sun Mar 18, 2018 6:57 pm

Re: Get a NetworkContext object to call url_request_context(

Postby magreenblatt » Fri Jul 24, 2020 12:31 pm

You would add a method to the NetworkContext interface and call that method from CefRequestContextImpl in CEF (see for example the CloseAllConnections implementation). This Chromium commit is an example of adding a new NetworkContext interface method.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Get a NetworkContext object to call url_request_context(

Postby user6294 » Fri Jul 24, 2020 2:47 pm

Hi Marshall,

Thank you for the references! I will look at the example implementations of the additional method added to the Mojo IPC Interface for NetworkContext.

So what you are saying is I can

- obtain the proxy of NetworkContext on the consumer side of Mojo, and
- invoke a newly added I/F method
- which calls the real url_request_context() method
- on NetworkContext object on the server side

Thanks
user6294
Mentor
 
Posts: 83
Joined: Sun Mar 18, 2018 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 115 guests