Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: mojo/services/network/main.cc

Issue 407593002: mojo: make NetworkServiceImpl clean up after itself (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/public/cpp/application/application_connection.h" 10 #include "mojo/public/cpp/application/application_connection.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 scoped_ptr<mojo::NetworkContext> context_; 59 scoped_ptr<mojo::NetworkContext> context_;
60 }; 60 };
61 61
62 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( 62 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain(
63 MojoHandle shell_handle) { 63 MojoHandle shell_handle) {
64 base::CommandLine::Init(0, NULL); 64 base::CommandLine::Init(0, NULL);
65 #if !defined(COMPONENT_BUILD) 65 #if !defined(COMPONENT_BUILD)
66 base::AtExitManager at_exit; 66 base::AtExitManager at_exit;
67 #endif 67 #endif
68 68
69 // The Delegate owns the NetworkContext, which needs to outlive
70 // MessageLoopForIO. Destruction of the message loop will serve to
71 // invalidate connections made to network services (URLLoader) and cause
72 // the service instances to be cleaned up as a result of observing pipe
73 // errors. This is important as ~URLRequestContext asserts that no out-
74 // standing URLRequests exist.
75 Delegate delegate;
darin (slow to review) 2014/07/19 03:54:44 I might call out the scoping a bit more explicitly
76
69 // The IO message loop allows us to use net::URLRequest on this thread. 77 // The IO message loop allows us to use net::URLRequest on this thread.
70 base::MessageLoopForIO loop; 78 base::MessageLoopForIO loop;
71 79
72 Delegate delegate;
73 mojo::ApplicationImpl app( 80 mojo::ApplicationImpl app(
74 &delegate, mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle))); 81 &delegate, mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)));
75 82
76 loop.Run(); 83 loop.Run();
77 return MOJO_RESULT_OK; 84 return MOJO_RESULT_OK;
78 } 85 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698