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 "mojo/edk/js/core.h" | 5 #include "mojo/edk/js/core.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "gin/arguments.h" | 12 #include "gin/arguments.h" |
13 #include "gin/array_buffer.h" | 13 #include "gin/array_buffer.h" |
14 #include "gin/converter.h" | 14 #include "gin/converter.h" |
15 #include "gin/dictionary.h" | 15 #include "gin/dictionary.h" |
16 #include "gin/function_template.h" | 16 #include "gin/function_template.h" |
17 #include "gin/handle.h" | 17 #include "gin/handle.h" |
18 #include "gin/object_template_builder.h" | 18 #include "gin/object_template_builder.h" |
19 #include "gin/per_isolate_data.h" | 19 #include "gin/per_isolate_data.h" |
20 #include "gin/public/wrapper_info.h" | 20 #include "gin/public/wrapper_info.h" |
21 #include "gin/wrappable.h" | 21 #include "gin/wrappable.h" |
22 #include "mojo/edk/js/drain_data.h" | 22 #include "mojo/edk/js/drain_data.h" |
23 #include "mojo/edk/js/handle.h" | 23 #include "mojo/edk/js/handle.h" |
24 | 24 |
25 namespace mojo { | 25 namespace mojo { |
26 namespace edk { | 26 namespace edk { |
| 27 namespace js { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 MojoResult CloseHandle(gin::Handle<HandleWrapper> handle) { | 31 MojoResult CloseHandle(gin::Handle<HandleWrapper> handle) { |
31 if (!handle->get().is_valid()) | 32 if (!handle->get().is_valid()) |
32 return MOJO_RESULT_INVALID_ARGUMENT; | 33 return MOJO_RESULT_INVALID_ARGUMENT; |
33 handle->Close(); | 34 handle->Close(); |
34 return MOJO_RESULT_OK; | 35 return MOJO_RESULT_OK; |
35 } | 36 } |
36 | 37 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // then the Promise is rejected, the result will be the actual error code, | 279 // then the Promise is rejected, the result will be the actual error code, |
279 // and the buffer will contain whatever was read before the error occurred. | 280 // and the buffer will contain whatever was read before the error occurred. |
280 // The drainData data pipe handle argument is closed automatically. | 281 // The drainData data pipe handle argument is closed automatically. |
281 | 282 |
282 v8::Handle<v8::Value> DoDrainData(gin::Arguments* args, | 283 v8::Handle<v8::Value> DoDrainData(gin::Arguments* args, |
283 gin::Handle<HandleWrapper> handle) { | 284 gin::Handle<HandleWrapper> handle) { |
284 return (new DrainData(args->isolate(), handle->release()))->GetPromise(); | 285 return (new DrainData(args->isolate(), handle->release()))->GetPromise(); |
285 } | 286 } |
286 | 287 |
287 bool IsHandle(gin::Arguments* args, v8::Handle<v8::Value> val) { | 288 bool IsHandle(gin::Arguments* args, v8::Handle<v8::Value> val) { |
288 gin::Handle<mojo::edk::HandleWrapper> ignore_handle; | 289 gin::Handle<mojo::edk::js::HandleWrapper> ignore_handle; |
289 return gin::Converter<gin::Handle<mojo::edk::HandleWrapper>>::FromV8( | 290 return gin::Converter<gin::Handle<mojo::edk::js::HandleWrapper>>::FromV8( |
290 args->isolate(), val, &ignore_handle); | 291 args->isolate(), val, &ignore_handle); |
291 } | 292 } |
292 | 293 |
293 | 294 |
294 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; | 295 gin::WrapperInfo g_wrapper_info = { gin::kEmbedderNativeGin }; |
295 | 296 |
296 } // namespace | 297 } // namespace |
297 | 298 |
298 const char Core::kModuleName[] = "mojo/public/js/core"; | 299 const char Core::kModuleName[] = "mojo/public/js/core"; |
299 | 300 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 .SetValue("READ_DATA_FLAG_QUERY", MOJO_READ_DATA_FLAG_QUERY) | 372 .SetValue("READ_DATA_FLAG_QUERY", MOJO_READ_DATA_FLAG_QUERY) |
372 .SetValue("READ_DATA_FLAG_PEEK", MOJO_READ_DATA_FLAG_PEEK) | 373 .SetValue("READ_DATA_FLAG_PEEK", MOJO_READ_DATA_FLAG_PEEK) |
373 .Build(); | 374 .Build(); |
374 | 375 |
375 data->SetObjectTemplate(&g_wrapper_info, templ); | 376 data->SetObjectTemplate(&g_wrapper_info, templ); |
376 } | 377 } |
377 | 378 |
378 return templ->NewInstance(); | 379 return templ->NewInstance(); |
379 } | 380 } |
380 | 381 |
| 382 } // namespace js |
381 } // namespace edk | 383 } // namespace edk |
382 } // namespace mojo | 384 } // namespace mojo |
OLD | NEW |