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 "sky/shell/ui/internals.h" | 5 #include "sky/shell/ui/internals.h" |
6 | 6 |
7 #include "base/threading/worker_pool.h" | 7 #include "base/threading/worker_pool.h" |
8 #include "mojo/public/cpp/application/connect.h" | 8 #include "mojo/public/cpp/application/connect.h" |
9 #include "mojo/public/cpp/bindings/array.h" | 9 #include "mojo/public/cpp/bindings/array.h" |
10 #include "services/asset_bundle/asset_unpacker_impl.h" | 10 #include "services/asset_bundle/asset_unpacker_impl.h" |
11 #include "sky/engine/tonic/dart_builtin.h" | 11 #include "sky/engine/tonic/dart_builtin.h" |
12 #include "sky/engine/tonic/dart_converter.h" | 12 #include "sky/engine/tonic/dart_converter.h" |
13 #include "sky/engine/tonic/dart_error.h" | 13 #include "sky/engine/tonic/dart_error.h" |
14 #include "sky/engine/tonic/dart_state.h" | 14 #include "sky/engine/tonic/dart_state.h" |
15 | 15 |
16 using namespace blink; | 16 using namespace blink; |
17 | 17 |
18 namespace sky { | 18 namespace sky { |
19 namespace shell { | 19 namespace shell { |
20 namespace { | 20 namespace { |
21 | 21 |
22 int kInternalsKey = 0; | 22 int kInternalsKey = 0; |
23 | 23 |
24 Internals* GetInternals() { | 24 Internals* GetInternals() { |
25 DartState* state = DartState::Current(); | 25 DartState* state = DartState::Current(); |
26 return static_cast<Internals*>(state->GetUserData(&kInternalsKey)); | 26 return static_cast<Internals*>(state->GetUserData(&kInternalsKey)); |
27 } | 27 } |
28 | 28 |
29 void ContentAsText(Dart_NativeArguments args) { | |
30 Dart_SetReturnValue(args, Dart_EmptyString()); | |
31 } | |
32 | |
33 void NotifyTestComplete(Dart_NativeArguments args) { | 29 void NotifyTestComplete(Dart_NativeArguments args) { |
34 } | 30 } |
35 | 31 |
36 void RenderTreeAsText(Dart_NativeArguments args) { | |
37 Dart_SetReturnValue(args, Dart_EmptyString()); | |
38 } | |
39 | |
40 void TakeShellProxyHandle(Dart_NativeArguments args) { | 32 void TakeShellProxyHandle(Dart_NativeArguments args) { |
41 Dart_SetIntegerReturnValue(args, 0); | 33 Dart_SetIntegerReturnValue(args, 0); |
42 } | 34 } |
43 | 35 |
44 void TakeServicesProvidedByEmbedder(Dart_NativeArguments args) { | 36 void TakeServicesProvidedByEmbedder(Dart_NativeArguments args) { |
45 Dart_SetIntegerReturnValue( | 37 Dart_SetIntegerReturnValue( |
46 args, GetInternals()->TakeServicesProvidedByEmbedder().value()); | 38 args, GetInternals()->TakeServicesProvidedByEmbedder().value()); |
47 } | 39 } |
48 | 40 |
49 void TakeServicesProvidedToEmbedder(Dart_NativeArguments args) { | 41 void TakeServicesProvidedToEmbedder(Dart_NativeArguments args) { |
50 Dart_SetIntegerReturnValue(args, 0); | 42 Dart_SetIntegerReturnValue(args, 0); |
51 } | 43 } |
52 | 44 |
53 void TakeServiceRegistry(Dart_NativeArguments args) { | 45 void TakeServiceRegistry(Dart_NativeArguments args) { |
54 Dart_SetIntegerReturnValue(args, 0); | 46 Dart_SetIntegerReturnValue(args, 0); |
55 } | 47 } |
56 | 48 |
57 const DartBuiltin::Natives kNativeFunctions[] = { | 49 const DartBuiltin::Natives kNativeFunctions[] = { |
58 {"contentAsText", ContentAsText, 0}, | |
59 {"notifyTestComplete", NotifyTestComplete, 1}, | 50 {"notifyTestComplete", NotifyTestComplete, 1}, |
60 {"renderTreeAsText", RenderTreeAsText, 0}, | |
61 {"takeShellProxyHandle", TakeShellProxyHandle, 0}, | 51 {"takeShellProxyHandle", TakeShellProxyHandle, 0}, |
62 {"takeServicesProvidedByEmbedder", TakeServicesProvidedByEmbedder, 0}, | 52 {"takeServicesProvidedByEmbedder", TakeServicesProvidedByEmbedder, 0}, |
63 {"takeServicesProvidedToEmbedder", TakeServicesProvidedToEmbedder, 0}, | 53 {"takeServicesProvidedToEmbedder", TakeServicesProvidedToEmbedder, 0}, |
64 {"takeServiceRegistry", TakeServiceRegistry, 0}, | 54 {"takeServiceRegistry", TakeServiceRegistry, 0}, |
65 }; | 55 }; |
66 | 56 |
67 const DartBuiltin& GetBuiltin() { | 57 const DartBuiltin& GetBuiltin() { |
68 static DartBuiltin& builtin = *new DartBuiltin(kNativeFunctions, | 58 static DartBuiltin& builtin = *new DartBuiltin(kNativeFunctions, |
69 arraysize(kNativeFunctions)); | 59 arraysize(kNativeFunctions)); |
70 return builtin; | 60 return builtin; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 new mojo::asset_bundle::AssetUnpackerImpl( | 101 new mojo::asset_bundle::AssetUnpackerImpl( |
112 request.Pass(), base::WorkerPool::GetTaskRunner(true)); | 102 request.Pass(), base::WorkerPool::GetTaskRunner(true)); |
113 } | 103 } |
114 | 104 |
115 mojo::Handle Internals::TakeServicesProvidedByEmbedder() { | 105 mojo::Handle Internals::TakeServicesProvidedByEmbedder() { |
116 return service_provider_.PassInterface().PassHandle().release(); | 106 return service_provider_.PassInterface().PassHandle().release(); |
117 } | 107 } |
118 | 108 |
119 } // namespace shell | 109 } // namespace shell |
120 } // namespace sky | 110 } // namespace sky |
OLD | NEW |