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

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

Issue 816113004: Dart: Adds a content handler and a test. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge CLs that address comments Created 5 years, 11 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"
7 #include "gin/public/isolate_holder.h"
8 #include "mojo/application/application_runner_chromium.h" 6 #include "mojo/application/application_runner_chromium.h"
9 #include "mojo/application/content_handler_factory.h" 7 #include "mojo/application/content_handler_factory.h"
10 #include "mojo/public/c/system/main.h" 8 #include "mojo/public/c/system/main.h"
11 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
12 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
13 #include "services/js/js_app.h" 11 #include "services/dart/dart_app.h"
14 12
15 namespace js { 13 namespace dart {
16 14
17 class JsContentHandler : public mojo::ApplicationDelegate, 15 class DartContentHandler : public mojo::ApplicationDelegate,
18 public mojo::ContentHandlerFactory::ManagedDelegate { 16 public mojo::ContentHandlerFactory::ManagedDelegate {
19 public: 17 public:
20 JsContentHandler() : content_handler_factory_(this) {} 18 DartContentHandler() : content_handler_factory_(this) {}
21 19
22 private: 20 private:
23 // Overridden from mojo::ApplicationDelegate: 21 // Overridden from mojo::ApplicationDelegate:
24 void Initialize(mojo::ApplicationImpl* app) override { 22 void Initialize(mojo::ApplicationImpl* app) override {
25 static const char v8Flags[] = "--harmony-classes";
26 v8::V8::SetFlagsFromString(v8Flags, sizeof(v8Flags) - 1);
27 base::i18n::InitializeICU(); 23 base::i18n::InitializeICU();
abarth-chromium 2015/01/16 05:43:43 You should use mojo::icu::Initialize() from //mojo
zra 2015/01/16 17:54:51 Done.
28 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
29 gin::ArrayBufferAllocator::SharedInstance());
30 } 24 }
31 25
32 // Overridden from ApplicationDelegate: 26 // Overridden from ApplicationDelegate:
33 bool ConfigureIncomingConnection( 27 bool ConfigureIncomingConnection(
34 mojo::ApplicationConnection* connection) override { 28 mojo::ApplicationConnection* connection) override {
35 connection->AddService(&content_handler_factory_); 29 connection->AddService(&content_handler_factory_);
36 return true; 30 return true;
37 } 31 }
38 32
39 // Overridden from ContentHandlerFactory::ManagedDelegate: 33 // Overridden from ContentHandlerFactory::ManagedDelegate:
40 scoped_ptr<mojo::ContentHandlerFactory::HandledApplicationHolder> 34 scoped_ptr<mojo::ContentHandlerFactory::HandledApplicationHolder>
41 CreateApplication(mojo::ShellPtr shell, 35 CreateApplication(mojo::ShellPtr shell,
42 mojo::URLResponsePtr response) override { 36 mojo::URLResponsePtr response) override {
43 return make_scoped_ptr(new JSApp(shell.Pass(), response.Pass())); 37 return make_scoped_ptr(new DartApp(shell.Pass(), response.Pass()));
44 } 38 }
45 39
46 mojo::ContentHandlerFactory content_handler_factory_; 40 mojo::ContentHandlerFactory content_handler_factory_;
47 41
48 DISALLOW_COPY_AND_ASSIGN(JsContentHandler); 42 DISALLOW_COPY_AND_ASSIGN(DartContentHandler);
49 }; 43 };
50 44
51 } // namespace js 45 } // namespace dart
52 46
53 MojoResult MojoMain(MojoHandle shell_handle) { 47 MojoResult MojoMain(MojoHandle shell_handle) {
54 mojo::ApplicationRunnerChromium runner(new js::JsContentHandler); 48 mojo::ApplicationRunnerChromium runner(new dart::DartContentHandler);
55 return runner.Run(shell_handle); 49 return runner.Run(shell_handle);
56 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698