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