Commit f6762f91 authored by tim@chromium.org's avatar tim@chromium.org

mojo: make NetworkServiceImpl clean up after itself

Each URLLoaderImpl created by NetworkServiceImpl can allocate a net::URLRequest.
When shutting down the app, destruction of the NetworkContext and the
URLRequestContext within it expects that all net::URLRequest resources have been
freed by now (it CHECKs). NetworkService is an app like any other and can't make
any assumptions about when it is being destroyed relative to other apps in the
system that may have been using it, so the safest thing to do is to have it
gracefully tear-down in-progress URLLoaders.

Note: the only reason we're not seeing the CHECK happen is because things
shut down (the process terminates) before we even get to ~URLRequestContext.
I'll be repairing shutdown in an upcoming CL.

BUG=394477

Review URL: https://codereview.chromium.org/407593002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284777 0039d316-1c4b-4281-b951-d872f2087c98
parent 506ae0e0
...@@ -43,13 +43,22 @@ extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( ...@@ -43,13 +43,22 @@ extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain(
base::AtExitManager at_exit; base::AtExitManager at_exit;
#endif #endif
// The IO message loop allows us to use net::URLRequest on this thread. // The Delegate owns the NetworkContext, which needs to outlive
base::MessageLoopForIO loop; // MessageLoopForIO. Destruction of the message loop will serve to
// invalidate connections made to network services (URLLoader) and cause
// the service instances to be cleaned up as a result of observing pipe
// errors. This is important as ~URLRequestContext asserts that no out-
// standing URLRequests exist.
Delegate delegate; Delegate delegate;
mojo::ApplicationImpl app( {
&delegate, mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle))); // The IO message loop allows us to use net::URLRequest on this thread.
base::MessageLoopForIO loop;
mojo::ApplicationImpl app(
&delegate,
mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)));
loop.Run(); loop.Run();
}
return MOJO_RESULT_OK; return MOJO_RESULT_OK;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment