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

Unified Diff: third_party/WebKit/Source/modules/nfc/NFC.cpp

Issue 2498543003: Mojo C++ bindings: switch device/nfc mojom target to use STL/WTF types. (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
« no previous file with comments | « third_party/WebKit/Source/modules/nfc/NFC.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/nfc/NFC.cpp
diff --git a/third_party/WebKit/Source/modules/nfc/NFC.cpp b/third_party/WebKit/Source/modules/nfc/NFC.cpp
index 37382c9308663ed399d8fc6b31535490cb9ac2cc..87fa30cbc5c1c6e710cf418c240726da319528ce 100644
--- a/third_party/WebKit/Source/modules/nfc/NFC.cpp
+++ b/third_party/WebKit/Source/modules/nfc/NFC.cpp
@@ -131,7 +131,7 @@ struct TypeConverter<NFCRecordPtr, WTF::String> {
record->record_type = NFCRecordType::TEXT;
record->media_type = kPlainTextMimeType;
record->media_type.append(kCharSetUTF8);
- record->data = mojo::WTFArray<uint8_t>::From(string);
+ record->data = mojo::WTFArray<uint8_t>::From(string).PassStorage();
return record;
}
};
@@ -142,7 +142,7 @@ struct TypeConverter<NFCRecordPtr, blink::DOMArrayBuffer*> {
NFCRecordPtr record = NFCRecord::New();
record->record_type = NFCRecordType::OPAQUE_RECORD;
record->media_type = kOpaqueMimeType;
- record->data = mojo::WTFArray<uint8_t>::From(buffer);
+ record->data = mojo::WTFArray<uint8_t>::From(buffer).PassStorage();
haraken 2016/11/12 01:35:41 Would you help me understand what PassStorage is d
yzshen1 2016/11/14 17:10:42 Because with this CL, record->data's type becomes
haraken 2016/11/14 18:38:30 Thanks, makes sense.
return record;
}
};
@@ -151,8 +151,7 @@ template <>
struct TypeConverter<NFCMessagePtr, WTF::String> {
static NFCMessagePtr Convert(const WTF::String& string) {
NFCMessagePtr message = NFCMessage::New();
- message->data = mojo::WTFArray<NFCRecordPtr>::New(1);
- message->data[0] = NFCRecord::From(string);
+ message->data.append(NFCRecord::From(string));
return message;
}
};
@@ -223,14 +222,14 @@ struct TypeConverter<NFCRecordPtr, blink::NFCRecord> {
break;
}
- recordPtr->data = mojo::WTFArray<uint8_t>::From(record.data());
-
+ auto recordData = mojo::WTFArray<uint8_t>::From(record.data());
// If JS object cannot be converted to uint8_t array, return null,
// interrupt NFCMessage conversion algorithm and reject promise with
// SyntaxError exception.
- if (recordPtr->data.is_null())
+ if (recordData.is_null())
return nullptr;
+ recordPtr->data = recordData.PassStorage();
return recordPtr;
}
};
@@ -248,7 +247,6 @@ struct TypeConverter<NFCMessagePtr, blink::NFCMessage> {
messagePtr->data[i] = std::move(record);
}
- messagePtr->data = mojo::WTFArray<NFCRecordPtr>::From(message.data());
haraken 2016/11/12 01:35:41 Why can we remove this?
yzshen1 2016/11/14 17:10:42 Because line 243-250 does the same thing as line 2
return messagePtr;
}
};
@@ -257,8 +255,7 @@ template <>
struct TypeConverter<NFCMessagePtr, blink::DOMArrayBuffer*> {
static NFCMessagePtr Convert(blink::DOMArrayBuffer* buffer) {
NFCMessagePtr message = NFCMessage::New();
- message->data = mojo::WTFArray<NFCRecordPtr>::New(1);
- message->data[0] = NFCRecord::From(buffer);
+ message->data.append(NFCRecord::From(buffer));
return message;
}
};
@@ -581,7 +578,7 @@ void NFC::OnConnectionError() {
m_requests.clear();
}
-void NFC::OnWatch(mojo::WTFArray<uint32_t> ids, mojom::NFCMessagePtr) {
+void NFC::OnWatch(const WTF::Vector<uint32_t>& ids, mojom::NFCMessagePtr) {
// TODO(shalamov): Not implemented.
}
« no previous file with comments | « third_party/WebKit/Source/modules/nfc/NFC.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698