Commit fa7b5bc7 authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Remove the && functions from protocol::Binary.

Just using std::move appropriately is probably
sufficient for avoiding extra copies and it's
easier to understand what's going on. Also less code.

Bug: chromium:891377
Change-Id: I321e969bdede991c223cf842a6a572704d060f11
Reviewed-on: https://chromium-review.googlesource.com/c/1302109
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603251}
parent d49f95cd
......@@ -196,25 +196,13 @@ Binary Binary::fromRefCounted(scoped_refptr<base::RefCountedMemory> memory) {
}
// static
Binary Binary::fromVector(std::vector<uint8_t>&& data) {
Binary Binary::fromVector(std::vector<uint8_t> data) {
return Binary(base::RefCountedBytes::TakeVector(&data));
}
// static
Binary Binary::fromVector(const std::vector<uint8_t>& data) {
std::vector<uint8_t> copied_data(data);
return Binary(base::RefCountedBytes::TakeVector(&copied_data));
}
// static
Binary Binary::fromString(std::string&& data) {
Binary Binary::fromString(std::string data) {
return Binary(base::RefCountedString::TakeString(&data));
}
// static
Binary Binary::fromString(const std::string& data) {
std::string copied_data(data);
return Binary(base::RefCountedString::TakeString(&copied_data));
}
} // namespace protocol
} // namespace content
......@@ -101,10 +101,8 @@ class CONTENT_EXPORT Binary {
static Binary fromBase64(const String& base64, bool* success);
static Binary fromRefCounted(scoped_refptr<base::RefCountedMemory> memory);
static Binary fromVector(std::vector<uint8_t>&& data);
static Binary fromVector(const std::vector<uint8_t>& data);
static Binary fromString(std::string&& data);
static Binary fromString(const std::string& data);
static Binary fromVector(std::vector<uint8_t> data);
static Binary fromString(std::string data);
private:
explicit Binary(scoped_refptr<base::RefCountedMemory> bytes);
......
......@@ -190,25 +190,13 @@ Binary Binary::fromRefCounted(scoped_refptr<base::RefCountedMemory> memory) {
}
// static
Binary Binary::fromVector(std::vector<uint8_t>&& data) {
Binary Binary::fromVector(std::vector<uint8_t> data) {
return Binary(base::RefCountedBytes::TakeVector(&data));
}
// static
Binary Binary::fromVector(const std::vector<uint8_t>& data) {
std::vector<uint8_t> copied_data(data);
return Binary(base::RefCountedBytes::TakeVector(&copied_data));
}
// static
Binary Binary::fromString(std::string&& data) {
Binary Binary::fromString(std::string data) {
return Binary(base::RefCountedString::TakeString(&data));
}
// static
Binary Binary::fromString(const std::string& data) {
std::string copied_data(data);
return Binary(base::RefCountedString::TakeString(&copied_data));
}
} // namespace protocol
} // namespace headless
......@@ -98,10 +98,8 @@ class HEADLESS_EXPORT Binary {
String toBase64() const;
static Binary fromBase64(const String& base64, bool* success);
static Binary fromRefCounted(scoped_refptr<base::RefCountedMemory> memory);
static Binary fromVector(std::vector<uint8_t>&& data);
static Binary fromVector(const std::vector<uint8_t>& data);
static Binary fromString(std::string&& data);
static Binary fromString(const std::string& data);
static Binary fromVector(std::vector<uint8_t> data);
static Binary fromString(std::string data);
private:
explicit Binary(scoped_refptr<base::RefCountedMemory> bytes);
......
......@@ -139,15 +139,10 @@ Binary Binary::fromSharedBuffer(scoped_refptr<SharedBuffer> buffer) {
}
// static
Binary Binary::fromVector(Vector<uint8_t>&& in) {
Binary Binary::fromVector(Vector<uint8_t> in) {
return Binary(base::AdoptRef(new BinaryBasedOnVector(std::move(in))));
}
// static
Binary Binary::fromVector(const Vector<uint8_t>& in) {
return Binary(base::AdoptRef(new BinaryBasedOnVector(in)));
}
// static
Binary Binary::fromCachedData(
std::unique_ptr<v8::ScriptCompiler::CachedData> data) {
......
......@@ -97,8 +97,7 @@ class CORE_EXPORT Binary {
String toBase64() const;
static Binary fromBase64(const String& base64, bool* success);
static Binary fromSharedBuffer(scoped_refptr<SharedBuffer> buffer);
static Binary fromVector(Vector<uint8_t>&& in);
static Binary fromVector(const Vector<uint8_t>& in);
static Binary fromVector(Vector<uint8_t> in);
// Note: |data.buffer_policy| must be
// ScriptCompiler::ScriptCompiler::CachedData::BufferOwned.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment