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

Unified Diff: mojo/dart/dart_snapshotter/logging.cc

Issue 1273743005: Dart: Adds a program to create snapshots of Mojo apps. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: mojo/dart/dart_snapshotter/logging.cc
diff --git a/tonic/dart_error.cc b/mojo/dart/dart_snapshotter/logging.cc
similarity index 57%
copy from tonic/dart_error.cc
copy to mojo/dart/dart_snapshotter/logging.cc
index c44877dcca428d2cede45b5f9f7fc0f6e624a374..7fb04834cc231067caa6c0aa950fc1bef3b3100a 100644
--- a/tonic/dart_error.cc
+++ b/mojo/dart/dart_snapshotter/logging.cc
@@ -2,18 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "tonic/dart_error.h"
+#include "mojo/dart/dart_snapshotter/logging.h"
#include "base/logging.h"
-namespace tonic {
-
-namespace DartError {
-
-const char kInvalidArgument[] = "Invalid argument.";
-
-} // namespace DartError
-
bool LogIfError(Dart_Handle handle) {
if (Dart_IsError(handle)) {
LOG(ERROR) << Dart_GetError(handle);
@@ -31,4 +23,15 @@ bool LogIfError(Dart_Handle handle) {
return false;
}
-} // namespace tonic
+std::string StringFromDart(Dart_Handle string) {
+ CHECK(Dart_IsString(string));
+ uint8_t* utf8_array;
+ intptr_t length;
+ Dart_StringToUTF8(string, &utf8_array, &length);
+ return std::string(reinterpret_cast<const char*>(utf8_array), length);
+}
+
+Dart_Handle StringToDart(const std::string& string) {
+ return Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(string.data()),
+ string.length());
+}

Powered by Google App Engine
This is Rietveld 408576698