OLD | NEW |
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/base_paths.h" | 6 #include "base/base_paths.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 "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 scoped_ptr<mojo::NetworkContext> context_; | 36 scoped_ptr<mojo::NetworkContext> context_; |
37 }; | 37 }; |
38 | 38 |
39 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( | 39 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( |
40 MojoHandle shell_handle) { | 40 MojoHandle shell_handle) { |
41 base::CommandLine::Init(0, NULL); | 41 base::CommandLine::Init(0, NULL); |
42 #if !defined(COMPONENT_BUILD) | 42 #if !defined(COMPONENT_BUILD) |
43 base::AtExitManager at_exit; | 43 base::AtExitManager at_exit; |
44 #endif | 44 #endif |
45 | 45 |
46 // The IO message loop allows us to use net::URLRequest on this thread. | 46 // The Delegate owns the NetworkContext, which needs to outlive |
47 base::MessageLoopForIO loop; | 47 // MessageLoopForIO. Destruction of the message loop will serve to |
| 48 // invalidate connections made to network services (URLLoader) and cause |
| 49 // the service instances to be cleaned up as a result of observing pipe |
| 50 // errors. This is important as ~URLRequestContext asserts that no out- |
| 51 // standing URLRequests exist. |
| 52 Delegate delegate; |
| 53 { |
| 54 // The IO message loop allows us to use net::URLRequest on this thread. |
| 55 base::MessageLoopForIO loop; |
48 | 56 |
49 Delegate delegate; | 57 mojo::ApplicationImpl app( |
50 mojo::ApplicationImpl app( | 58 &delegate, |
51 &delegate, mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle))); | 59 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle))); |
52 | 60 |
53 loop.Run(); | 61 loop.Run(); |
| 62 } |
54 return MOJO_RESULT_OK; | 63 return MOJO_RESULT_OK; |
55 } | 64 } |
OLD | NEW |