diff options
author | jam <jam@chromium.org> | 2015-05-19 10:35:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-19 17:36:19 +0000 |
commit | e152cdb102e5e495dd3aa124a512ea750b47c04c (patch) | |
tree | 94ccb226918b370a3524711fcb2b8c071c8d0bd2 /mojo/services/network/network_service_impl.cc | |
parent | 5849cfec2bbfc5e16a3c033c15e73d09a1b6af4f (diff) | |
download | chromium_src-e152cdb102e5e495dd3aa124a512ea750b47c04c.zip chromium_src-e152cdb102e5e495dd3aa124a512ea750b47c04c.tar.gz chromium_src-e152cdb102e5e495dd3aa124a512ea750b47c04c.tar.bz2 |
Making Mandoline apps notice when all the objects they vended are gone so that it can terminate.
With this change, closing the window shuts down Mandoline cleanly.
This is split off https://codereview.chromium.org/1139673003
BUG=484234
Review URL: https://codereview.chromium.org/1131933009
Cr-Commit-Position: refs/heads/master@{#330550}
Diffstat (limited to 'mojo/services/network/network_service_impl.cc')
-rw-r--r-- | mojo/services/network/network_service_impl.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/mojo/services/network/network_service_impl.cc b/mojo/services/network/network_service_impl.cc index 20c2558..fe44530 100644 --- a/mojo/services/network/network_service_impl.cc +++ b/mojo/services/network/network_service_impl.cc @@ -15,9 +15,12 @@ namespace mojo { -NetworkServiceImpl::NetworkServiceImpl(ApplicationConnection* connection, - NetworkContext* context) +NetworkServiceImpl::NetworkServiceImpl( + ApplicationConnection* connection, + NetworkContext* context, + scoped_ptr<mojo::AppRefCount> app_refcount) : context_(context), + app_refcount_(app_refcount.Pass()), origin_(GURL(connection->GetRemoteApplicationURL()).GetOrigin()) { } @@ -29,22 +32,24 @@ void NetworkServiceImpl::CreateURLLoader(InterfaceRequest<URLLoader> loader) { // The loader will delete itself when the pipe is closed, unless a request is // in progress. In which case, the loader will delete itself when the request // is finished. - new URLLoaderImpl(context_, loader.Pass()); + new URLLoaderImpl(context_, loader.Pass(), app_refcount_->Clone()); } void NetworkServiceImpl::GetCookieStore(InterfaceRequest<CookieStore> store) { - BindToRequest(new CookieStoreImpl(context_, origin_), &store); + BindToRequest(new CookieStoreImpl(context_, origin_, app_refcount_->Clone()), + &store); } void NetworkServiceImpl::CreateWebSocket(InterfaceRequest<WebSocket> socket) { - BindToRequest(new WebSocketImpl(context_), &socket); + BindToRequest(new WebSocketImpl(context_, app_refcount_->Clone()), &socket); } void NetworkServiceImpl::CreateTCPBoundSocket( NetAddressPtr local_address, InterfaceRequest<TCPBoundSocket> bound_socket, const CreateTCPBoundSocketCallback& callback) { - scoped_ptr<TCPBoundSocketImpl> bound(new TCPBoundSocketImpl); + scoped_ptr<TCPBoundSocketImpl> bound(new TCPBoundSocketImpl( + app_refcount_->Clone())); int net_error = bound->Bind(local_address.Pass()); if (net_error != net::OK) { callback.Run(MakeNetworkError(net_error), NetAddressPtr()); @@ -69,14 +74,15 @@ void NetworkServiceImpl::CreateTCPConnectedSocket( void NetworkServiceImpl::CreateUDPSocket(InterfaceRequest<UDPSocket> request) { // The lifetime of this UDPSocketImpl is bound to that of the underlying pipe. - new UDPSocketImpl(request.Pass()); + new UDPSocketImpl(request.Pass(), app_refcount_->Clone()); } void NetworkServiceImpl::CreateHttpServer( NetAddressPtr local_address, HttpServerDelegatePtr delegate, const CreateHttpServerCallback& callback) { - HttpServerImpl::Create(local_address.Pass(), delegate.Pass(), callback); + HttpServerImpl::Create(local_address.Pass(), delegate.Pass(), + app_refcount_->Clone(), callback); } } // namespace mojo |