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

Unified Diff: third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h

Issue 2464793004: Mojo C++ bindings: some improvements for String16 struct traits. (Closed)
Patch Set: . Created 4 years, 1 month 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: third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h
diff --git a/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h b/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h
index 3318ad8fc1eab3d617c7a892bae11eb2d5ab5aeb..40595811d9769a9f7fdece63cdba4895cf9ff7cf 100644
--- a/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h
+++ b/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraits.h
@@ -5,6 +5,7 @@
#ifndef CommonCustomTypesStructTraits_h
#define CommonCustomTypesStructTraits_h
+#include "base/strings/string16.h"
#include "mojo/common/common_custom_types.mojom-blink.h"
#include "platform/PlatformExport.h"
@@ -12,9 +13,17 @@ namespace mojo {
template <>
struct PLATFORM_EXPORT
- StructTraits<mojo::common::mojom::String16DataView, ::WTF::String> {
- static WTF::Vector<uint16_t> data(const ::WTF::String&);
- static bool Read(mojo::common::mojom::String16DataView, ::WTF::String* out);
+ StructTraits<common::mojom::String16DataView, WTF::String> {
+ static bool IsNull(const WTF::String& input) { return input.isNull(); }
+ static void SetToNull(WTF::String* output) { *output = WTF::String(); }
+
+ static void* SetUpContext(const WTF::String& input);
+ static void TearDownContext(const WTF::String& input, void* context) {
+ delete static_cast<base::string16*>(context);
+ }
+
+ static ConstCArray<uint16_t> data(const WTF::String& input, void* context);
+ static bool Read(common::mojom::String16DataView, WTF::String* out);
};
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698