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

Side by Side Diff: runtime/bin/dartutils.h

Issue 1852783003: Implements remaining SecurityContext calls for iOS (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 8 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
« no previous file with comments | « no previous file | runtime/bin/io_impl_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_DARTUTILS_H_ 5 #ifndef BIN_DARTUTILS_H_
6 #define BIN_DARTUTILS_H_ 6 #define BIN_DARTUTILS_H_
7 7
8 #include "bin/isolate_data.h" 8 #include "bin/isolate_data.h"
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_native_api.h" 10 #include "include/dart_native_api.h"
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 593
594 class ScopedBlockingCall { 594 class ScopedBlockingCall {
595 public: 595 public:
596 ScopedBlockingCall() { 596 ScopedBlockingCall() {
597 Dart_ThreadDisableProfiling(); 597 Dart_ThreadDisableProfiling();
598 } 598 }
599 599
600 ~ScopedBlockingCall() { 600 ~ScopedBlockingCall() {
601 Dart_ThreadEnableProfiling(); 601 Dart_ThreadEnableProfiling();
602 } 602 }
603
604 private:
605 DISALLOW_ALLOCATION();
606 DISALLOW_COPY_AND_ASSIGN(ScopedBlockingCall);
607 };
608
609
610 // Where the argument to the constructor is the handle for an object
611 // implementing List<int>, this class creates a scope in which the memory
612 // backing the list can be accessed.
613 //
614 // Do not make Dart_ API calls while in a ScopedMemBuffer.
615 // Do not call Dart_PropagateError while in a ScopedMemBuffer.
616 class ScopedMemBuffer {
617 public:
618 explicit ScopedMemBuffer(Dart_Handle object) {
619 if (!Dart_IsTypedData(object) && !Dart_IsList(object)) {
620 Dart_ThrowException(DartUtils::NewDartArgumentError(
621 "Argument is not a List<int>"));
622 }
623
624 uint8_t* bytes = NULL;
625 intptr_t bytes_len = 0;
626 bool is_typed_data = false;
627 if (Dart_IsTypedData(object)) {
628 is_typed_data = true;
629 Dart_TypedData_Type typ;
630 ThrowIfError(Dart_TypedDataAcquireData(
631 object,
632 &typ,
633 reinterpret_cast<void**>(&bytes),
634 &bytes_len));
635 } else {
636 ASSERT(Dart_IsList(object));
637 ThrowIfError(Dart_ListLength(object, &bytes_len));
638 bytes = Dart_ScopeAllocate(bytes_len);
639 ASSERT(bytes != NULL);
640 ThrowIfError(Dart_ListGetAsBytes(object, 0, bytes, bytes_len));
641 }
642
643 object_ = object;
644 bytes_ = bytes;
645 bytes_len_ = bytes_len;
646 is_typed_data_ = is_typed_data;
647 }
648
649 ~ScopedMemBuffer() {
650 if (is_typed_data_) {
651 ThrowIfError(Dart_TypedDataReleaseData(object_));
652 }
653 }
654
655 uint8_t* get() const { return bytes_; }
656 intptr_t length() const { return bytes_len_; }
657
658 private:
659 Dart_Handle object_;
660 uint8_t* bytes_;
661 intptr_t bytes_len_;
662 bool is_typed_data_;
663
664 DISALLOW_ALLOCATION();
665 DISALLOW_COPY_AND_ASSIGN(ScopedMemBuffer);
603 }; 666 };
604 667
605 } // namespace bin 668 } // namespace bin
606 } // namespace dart 669 } // namespace dart
607 670
608 #endif // BIN_DARTUTILS_H_ 671 #endif // BIN_DARTUTILS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/io_impl_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698