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 3 // found in the LICENSE file. 4 5 #include "base/at_exit.h" 6 #include "base/command_line.h" 7 #include "base/message_loop/message_loop.h" 8 #include "mojo/public/cpp/application/application.h" 9 #include "mojo/services/network/network_context.h" 10 #include "mojo/services/network/network_service_impl.h" 11 MojoMain(MojoHandle service_provider_handle)12extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( 13 MojoHandle service_provider_handle) { 14 base::CommandLine::Init(0, NULL); 15 base::AtExitManager at_exit; 16 17 // The IO message loop allows us to use net::URLRequest on this thread. 18 base::MessageLoopForIO loop; 19 20 mojo::NetworkContext context; 21 22 mojo::Application app; 23 app.BindServiceProvider( 24 mojo::MakeScopedHandle(mojo::MessagePipeHandle(service_provider_handle))); 25 26 app.AddService<mojo::NetworkServiceImpl>(&context); 27 28 loop.Run(); 29 return MOJO_RESULT_OK; 30 } 31