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

Side by Side Diff: services/js/content_handler_main.cc

Issue 2005103003: Add implementations of mojo::{Run,Terminate}[Main]Application() for "chromium". (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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
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/i18n/icu_util.h" 5 #include "base/i18n/icu_util.h"
6 #include "gin/array_buffer.h" 6 #include "gin/array_buffer.h"
7 #include "gin/public/isolate_holder.h" 7 #include "gin/public/isolate_holder.h"
8 #include "mojo/application/application_runner_chromium.h"
9 #include "mojo/application/content_handler_factory.h" 8 #include "mojo/application/content_handler_factory.h"
10 #include "mojo/public/c/system/main.h" 9 #include "mojo/public/c/system/main.h"
11 #include "mojo/public/cpp/application/application_delegate.h" 10 #include "mojo/public/cpp/application/application_impl_base.h"
12 #include "mojo/public/cpp/application/application_impl.h" 11 #include "mojo/public/cpp/application/run_application.h"
13 #include "services/js/js_app.h" 12 #include "services/js/js_app.h"
14 13
15 namespace js { 14 namespace js {
16 15
17 class JsContentHandler : public mojo::ApplicationDelegate, 16 class JsContentHandler : public mojo::ApplicationImplBase,
18 public mojo::ContentHandlerFactory::ManagedDelegate { 17 public mojo::ContentHandlerFactory::ManagedDelegate {
19 public: 18 public:
20 JsContentHandler() {} 19 JsContentHandler() {}
21 20
22 private: 21 private:
23 // Overridden from mojo::ApplicationDelegate: 22 // Overridden from mojo::ApplicationImplBase:
24 void Initialize(mojo::ApplicationImpl* app) override { 23 void OnInitialize() override {
25 static const char v8Flags[] = "--harmony-classes"; 24 static const char v8Flags[] = "--harmony-classes";
26 v8::V8::SetFlagsFromString(v8Flags, sizeof(v8Flags) - 1); 25 v8::V8::SetFlagsFromString(v8Flags, sizeof(v8Flags) - 1);
27 base::i18n::InitializeICU(); 26 base::i18n::InitializeICU();
28 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, 27 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
29 gin::ArrayBufferAllocator::SharedInstance()); 28 gin::ArrayBufferAllocator::SharedInstance());
30 } 29 }
31 30
32 // Overridden from ApplicationDelegate: 31 // Overridden from mojo::ApplicationImplBase:
33 bool ConfigureIncomingConnection( 32 bool OnAcceptConnection(
34 mojo::ServiceProviderImpl* service_provider_impl) override { 33 mojo::ServiceProviderImpl* service_provider_impl) override {
35 service_provider_impl->AddService<mojo::ContentHandler>( 34 service_provider_impl->AddService<mojo::ContentHandler>(
36 mojo::ContentHandlerFactory::GetInterfaceRequestHandler(this)); 35 mojo::ContentHandlerFactory::GetInterfaceRequestHandler(this));
37 return true; 36 return true;
38 } 37 }
39 38
40 // Overridden from ContentHandlerFactory::ManagedDelegate: 39 // Overridden from mojo::ContentHandlerFactory::ManagedDelegate:
41 scoped_ptr<mojo::ContentHandlerFactory::HandledApplicationHolder> 40 scoped_ptr<mojo::ContentHandlerFactory::HandledApplicationHolder>
42 CreateApplication( 41 CreateApplication(
43 mojo::InterfaceRequest<mojo::Application> application_request, 42 mojo::InterfaceRequest<mojo::Application> application_request,
44 mojo::URLResponsePtr response) override { 43 mojo::URLResponsePtr response) override {
45 return make_scoped_ptr( 44 return make_scoped_ptr(
46 new JSApp(application_request.Pass(), response.Pass())); 45 new JSApp(application_request.Pass(), response.Pass()));
47 } 46 }
48 47
49 DISALLOW_COPY_AND_ASSIGN(JsContentHandler); 48 DISALLOW_COPY_AND_ASSIGN(JsContentHandler);
50 }; 49 };
51 50
52 } // namespace js 51 } // namespace js
53 52
54 MojoResult MojoMain(MojoHandle application_request) { 53 MojoResult MojoMain(MojoHandle application_request) {
55 mojo::ApplicationRunnerChromium runner(new js::JsContentHandler); 54 js::JsContentHandler js_content_handler;
56 return runner.Run(application_request); 55 return mojo::RunMainApplication(application_request, &js_content_handler);
57 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698