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

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

Issue 441853002: mojo: first take on removing mojo_main_{chromium,standalone}. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: seperate Run call Created 6 years, 4 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
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/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"
11 #include "mojo/public/cpp/application/application_connection.h" 11 #include "mojo/public/cpp/application/application_connection.h"
12 #include "mojo/public/cpp/application/application_delegate.h" 12 #include "mojo/public/cpp/application/application_delegate.h"
13 #include "mojo/public/cpp/application/application_export.h"
13 #include "mojo/public/cpp/application/application_impl.h" 14 #include "mojo/public/cpp/application/application_impl.h"
15 #include "mojo/public/cpp/application/application_runner_chromium.h"
14 #include "mojo/public/cpp/application/interface_factory.h" 16 #include "mojo/public/cpp/application/interface_factory.h"
15 #include "mojo/public/cpp/bindings/interface_ptr.h" 17 #include "mojo/public/cpp/bindings/interface_ptr.h"
16 #include "mojo/services/network/network_context.h" 18 #include "mojo/services/network/network_context.h"
17 #include "mojo/services/network/network_service_impl.h" 19 #include "mojo/services/network/network_service_impl.h"
18 20
19 class Delegate : public mojo::ApplicationDelegate, 21 class Delegate : public mojo::ApplicationDelegate,
20 public mojo::InterfaceFactory<mojo::NetworkService> { 22 public mojo::InterfaceFactory<mojo::NetworkService> {
21 public: 23 public:
22 Delegate() {} 24 Delegate() {}
23 25
(...skipping 19 matching lines...) Expand all
43 mojo::BindToRequest( 45 mojo::BindToRequest(
44 new mojo::NetworkServiceImpl(connection, context_.get()), &request); 46 new mojo::NetworkServiceImpl(connection, context_.get()), &request);
45 } 47 }
46 48
47 private: 49 private:
48 scoped_ptr<mojo::NetworkContext> context_; 50 scoped_ptr<mojo::NetworkContext> context_;
49 }; 51 };
50 52
51 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( 53 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain(
52 MojoHandle shell_handle) { 54 MojoHandle shell_handle) {
53 base::CommandLine::Init(0, NULL); 55 mojo::ApplicationRunnerChromium runner(new Delegate);
54 #if !defined(COMPONENT_BUILD) 56 runner.set_loop_type(base::MessageLoop::TYPE_IO);
darin (slow to review) 2014/08/18 23:38:18 nit: spell it out: set_message_loop_type
tim (not reviewing) 2014/08/19 00:06:30 Done.
55 base::AtExitManager at_exit; 57 return runner.Run(shell_handle);
56 #endif
57
58 // The Delegate owns the NetworkContext, which needs to outlive
59 // MessageLoopForIO. Destruction of the message loop will serve to
60 // invalidate connections made to network services (URLLoader) and cause
61 // the service instances to be cleaned up as a result of observing pipe
62 // errors. This is important as ~URLRequestContext asserts that no out-
63 // standing URLRequests exist.
64 Delegate delegate;
65 {
66 // The IO message loop allows us to use net::URLRequest on this thread.
67 base::MessageLoopForIO loop;
68
69 mojo::ApplicationImpl app(
70 &delegate,
71 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)));
72
73 loop.Run();
74 }
75 return MOJO_RESULT_OK;
76 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698