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/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 Loading... | |
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 } |
OLD | NEW |